summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-04-10 09:00:46 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-04-10 09:00:46 -0700
commit69d9a57ddcfb6d9b51ce321bd2557881c6784151 (patch)
tree6e603216367a9fce7f9c8c68a9da4a2277d2cab8 /lib
parent4073e537492ac700f926d1ed0f27d6160a142ae4 (diff)
downloademacs-69d9a57ddcfb6d9b51ce321bd2557881c6784151.tar.gz
Merge from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/careadlinkat.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c
index 01883db9ce5..e2909c766d5 100644
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -22,10 +22,9 @@
#include "careadlinkat.h"
-#include "allocator.h"
-
#include <errno.h>
#include <limits.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -38,15 +37,20 @@
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
+#include "allocator.h"
+
#if ! HAVE_READLINKAT
-/* Ignore FD. Get the symbolic link value of FILENAME and put it into
- BUFFER, with size BUFFER_SIZE. This function acts like readlink
- but has readlinkat's signature. */
+/* Get the symbolic link value of FILENAME and put it into BUFFER, with
+ size BUFFER_SIZE. This function acts like readlink but has
+ readlinkat's signature. */
ssize_t
careadlinkatcwd (int fd, char const *filename, char *buffer,
size_t buffer_size)
{
- (void) fd;
+ /* FD must be AT_FDCWD here, otherwise the caller is using this
+ function in contexts for which it was not meant for. */
+ if (fd != AT_FDCWD)
+ abort ();
return readlink (filename, buffer, buffer_size);
}
#endif