[PATCH] tst-realpath-toolong: Fix hurd build

Siddhesh Poyarekar siddhesh@sourceware.org
Sun Jan 23 15:19:48 GMT 2022


On 23/01/2022 06:06, Samuel Thibault wrote:
> Siddhesh Poyarekar via Libc-alpha, le sam. 22 janv. 2022 20:15:23 +0530, a ecrit:
>> We don't really need a bigger buffer for realpath since it should fail
>> and return NULL.  In the bug too, the buffer itself is not accessed; it
>> is in fact left untouched.  Drop the PATH_MAX use and pass a single char
>> address.
> 
> ? realpath assumes that the passed buffer is PATH_MAX-long. When
> PATH_MAX is not defined, calling it with a buffer is essentially
> undefined. Better just pass NULL.

Passing NULL doesn't reproduce the problem because realpath just 
allocates enough to accommodate the return, even when it exceeds 
PATH_MAX.  It only applies when a non-NULL buffer is supplied.

Would you prefer it if I defined PATH_MAX on hurd then, something like:

#ifndef PATH_MAX
# define PATH_MAX 1024
#endif

or do you prefer a more accurate path_max value using pathconf()?

The former will be a simpler fix, the latter will be best served by a 
get_path_max support function, which will be more elaborate but 
accurate.  I'm happy to do either.

Thanks,
Siddhesh


More information about the Libc-alpha mailing list