diff options
Diffstat (limited to 'lib/areadlinkat-with-size.c')
-rw-r--r-- | lib/areadlinkat-with-size.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/areadlinkat-with-size.c b/lib/areadlinkat-with-size.c index 142b9dc542..09da28e816 100644 --- a/lib/areadlinkat-with-size.c +++ b/lib/areadlinkat-with-size.c @@ -1,11 +1,11 @@ /* readlinkat wrapper to return the link name in malloc'd storage. Unlike xreadlinkat, only call exit on failure to change directory. - Copyright (C) 2001, 2003-2007, 2009-2020 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -32,10 +32,6 @@ #if HAVE_READLINKAT -# ifndef SSIZE_MAX -# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) -# endif - /* SYMLINK_MAX is used only for an initial memory-allocation sanity check, so it's OK to guess too small on hosts where there is no arbitrary limit to symbolic link length. */ @@ -84,19 +80,17 @@ areadlinkat_with_size (int fd, char const *file, size_t size) { buf = buffer = malloc (buf_size); if (!buffer) + /* We can assume errno == ENOMEM here, since all platforms that have + readlinkat() have a POSIX compliant malloc(). */ return NULL; } r = readlinkat (fd, file, buf, buf_size); link_length = r; - /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 - with errno == ERANGE if the buffer is too small. */ - if (r < 0 && errno != ERANGE) + if (r < 0) { - int saved_errno = errno; free (buffer); - errno = saved_errno; return NULL; } |