[PATCH] improve out-of-bounds checking with GCC 10 attribute access [BZ #25219]

DJ Delorie dj@redhat.com
Wed May 6 21:08:09 GMT 2020


Joseph Myers <joseph@codesourcery.com> writes:
> test-errno.c:122:30: error: argument 1 value -1 is negative [-Werror=stringop-overflow=]

"size" is "int" but passing a negative buffer size?  If gcc knows that
the size is a count of elements, a warning (or error, if -Werror) seems
appropriate (if annoying ;).  However, I can see we're now in the "how
do I dumb down gcc so I can test things I know it knows are errors?"
territory.

Probably a #pramga GCC warning no-stringop-overflow or equivalent for
that whole test.

> test-errno.c:137:30: error: 'readlink' specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]

Here you're passing -1 to a size_t argument, I think that test needs
tweaking anyway.

>   137 |   fails |= test_wrp (EINVAL, readlink, "/", buf, -1);



More information about the Libc-alpha mailing list