[PATCH] canonicalize: Fix uninitialized 'dest' in realpath_stk for glibc 2.35 [BZ #32577]

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Jan 20 12:50:09 GMT 2025



On 20/01/25 09:25, Nikhil R wrote:
> Fixes a GCC warning when compiling with the '-Os' optimization flag:
> | canonicalize.c: In function 'realpath_stk':
> | canonicalize.c:424:50: error: 'dest' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> |   424 |   return scratch_buffer_dupfree (rname_buf, dest - rname);
> 
> Issue specific to glibc 2.35.

Hi Nikhil,

It is not our policy to accept new patch for old releases, the usual way
is to check if the same issue happens on master, and if it were the case
create a patch against it.  

Otherwise, either the release manager or other maintainer should check the 
required backports to fix this issue.  Also, old releases might not build
cleanly with newer gcc releases due extra warnings added over the releases,
so it might require even additional patches.

At least I can confirm that 949ad78a189194048, b416555431b47a21, and
ef0700004bf0dccf493 does fix the build issue with gcc-10 on x86_64-linux-gnu.
I still seeing warning issues on aarch64.

Another possibility is to build glibc with --disable-werror.  In any case,
I don't think this is valid issue.

> 
> Signed-off-by: Nikhil R <nikhilar2410@gmail.com>
> ---
>  stdlib/canonicalize.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
> index 6caed9e70e..061d3b3062 100644
> --- a/stdlib/canonicalize.c
> +++ b/stdlib/canonicalize.c
> @@ -198,7 +198,7 @@ static char *
>  realpath_stk (const char *name, char *resolved,
>                struct scratch_buffer *rname_buf)
>  {
> -  char *dest;
> +  char *dest = NULL;
>    char const *start;
>    char const *end;
>    int num_links = 0;



More information about the Libc-alpha mailing list