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

Florian Weimer fweimer@redhat.com
Mon Jan 20 14:38:14 GMT 2025


* Florian Weimer:

> * Nikhil R.:
>
>> 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.
>>
>> 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;
>
> We discussed this during the patch review call.  We should backport the
> stdlib/canonicalize.c fixes to 2.35 instead.  I'll take care of that.

Now done.

Florian



More information about the Libc-alpha mailing list