Philipp Tomsich <philipp.toms...@vrull.eu> writes:
> Fixes: 341573406b39
>
> Don't subtract one from the result of strnlen() when trying to point
> to the first character after the current string.  This issue would
> cause individual characters (where the 128 byte buffers are stitched
> together) to be lost.
>
> gcc/ChangeLog:
>
>       * config/aarch64/driver-aarch64.cc (readline): Fix off-by-one.
>
> Signed-off-by: Philipp Tomsich <philipp.toms...@vrull.eu>

Thanks for the patch.  Would it be possible to create a testcase along
the lines of gcc.target/aarch64/cpunative/native_cpu_15.c?

Richard

> ---
>
>  gcc/config/aarch64/driver-aarch64.cc | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/aarch64/driver-aarch64.cc 
> b/gcc/config/aarch64/driver-aarch64.cc
> index 52ff537908e..48250e68034 100644
> --- a/gcc/config/aarch64/driver-aarch64.cc
> +++ b/gcc/config/aarch64/driver-aarch64.cc
> @@ -203,9 +203,9 @@ readline (FILE *f)
>       return std::string ();
>        /* If we're not at the end of the line then override the
>        \0 added by fgets.  */
> -      last = strnlen (buf, size) - 1;
> +      last = strnlen (buf, size);
>      }
> -  while (!feof (f) && buf[last] != '\n');
> +  while (!feof (f) && (last > 0 && buf[last - 1] != '\n'));
>  
>    std::string result (buf);
>    free (buf);

Reply via email to