[Bug nss/32465] ./getaddrinfo.c:1884:11: error: variable 'endp' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]

cvs-commit at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Sun Dec 22 23:49:00 GMT 2024


https://sourceware.org/bugzilla/show_bug.cgi?id=32465

--- Comment #5 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=33aeb88c5bc9a0c6b1bd7190a0ead7570972b719

commit 33aeb88c5bc9a0c6b1bd7190a0ead7570972b719
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 17 15:18:36 2024 +0800

    getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]

    Add valid_decimal_value to check valid decimal value in a string to
    avoid uninitialized endp in add_prefixlist and gaiconf_init as reported
    by Clang 19:

    ./getaddrinfo.c:1884:11: error: variable 'endp' is used uninitialized
whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
     1884 |       && (cp == NULL
          |           ^~~~~~~~~~
    ./getaddrinfo.c:1887:11: note: uninitialized use occurs here
     1887 |       && *endp == '\0'
          |           ^~~~
    ./getaddrinfo.c:1884:11: note: remove the '||' if its condition is always
false
     1884 |       && (cp == NULL
          |           ^~~~~~~~~~
     1885 |           || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
          |           ~~
    ./getaddrinfo.c:1875:13: note: initialize the variable 'endp' to silence
this warning
     1875 |   char *endp;
          |             ^
          |              = NULL

    This fixes BZ #32465.

    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
    Reviewed-by: Sam James <sam@gentoo.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list