[PATCH] adjust thread db function declarations to match definitions (BZ 26686)
Florian Weimer
fweimer@redhat.com
Tue Oct 6 07:58:26 GMT 2020
* Martin Sebor via Libc-alpha:
> Similar to the issue with the RPC function declarations, building
> Glibc with the latest GCC 11 also shows a couple of instances of
> the new -Warray-parameter warning in the thread db APIs.
>
> To avoid these, the attached patch changes the deefinitions of
> the two functions to match their definitions.
>
> I tested the patch by building Glibc with GCC trunk and confirming
> the warnings are gone, and by running the tests and confirming no
> new failures in the test suite.
Patch looks fine to me.
> PS The functions only appear to access the first element of the array
> (via the DB_DESC_SIZE() macro), so I at first thought an alternate
> change might be to have both their declarations and definitions take
> a uint32_t[1] instead. But it turns out that they call
> _td_locate_field with the array as an argument, and that function
> accesses all three elements. So declaring them to take uint32_t[1]
> leads to warnings about _td_locate_field accessing the array past
> its end.
Didn't we have a previous static analysis report that pointed to a
buffer overflow in these functions, and we couldn't figure out what was
going on because the actual allocation was large enough? The paragraph
above certainly would explain this, assuming the other tool also took
the [2] array size to mean that only two elements can be accessed.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
More information about the Libc-alpha
mailing list