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

Samuel Thibault samuel.thibault@aquilenet.fr
Sun Jan 23 00:36:00 GMT 2022


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.

> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
> ---
>  stdlib/tst-realpath-toolong.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/stdlib/tst-realpath-toolong.c b/stdlib/tst-realpath-toolong.c
> index 8bed772460..ed84787a32 100644
> --- a/stdlib/tst-realpath-toolong.c
> +++ b/stdlib/tst-realpath-toolong.c
> @@ -34,8 +34,8 @@ do_test (void)
>  {
>    char *base = support_create_and_chdir_toolong_temp_directory (BASENAME);
>  
> -  char buf[PATH_MAX + 1];
> -  const char *res = realpath (".", buf);
> +  char buf;
> +  const char *res = realpath (".", &buf);
>  
>    /* canonicalize.c states that if the real path is >= PATH_MAX, then
>       realpath returns NULL and sets ENAMETOOLONG.  */
> -- 
> 2.34.1
> 


More information about the Libc-alpha mailing list