summaryrefslogtreecommitdiff
path: root/libbb/xreadlink.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-07 17:48:28 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-07 17:48:28 +0000
commit28355a36da6ad4d1b55ba9bb146fb0b6586e7edb (patch)
treed08439547c9b94e1d0211fb0de91e68fc3180fe4 /libbb/xreadlink.c
parent822c3837f95a355f90d25aaabeb2445bb5eb1bf0 (diff)
downloadbusybox-28355a36da6ad4d1b55ba9bb146fb0b6586e7edb.tar.gz
Per some comments from Lars Kellogg-Stedman <lars@larsshack.org>,
make xreadlink() return NULL on failure, and make sure everyone uses the interface correctly. -Erik
Diffstat (limited to 'libbb/xreadlink.c')
-rw-r--r--libbb/xreadlink.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c
index 66f63b883..932e487a5 100644
--- a/libbb/xreadlink.c
+++ b/libbb/xreadlink.c
@@ -1,5 +1,6 @@
/*
- * xreadlink.c - safe implementation of readlink
+ * xreadlink.c - safe implementation of readlink.
+ * Returns a NULL on failure...
*/
#include <stdio.h>
@@ -22,8 +23,10 @@ extern char *xreadlink(const char *path)
do {
buf = xrealloc(buf, bufsize += GROWBY);
readsize = readlink(path, buf, bufsize); /* 1st try */
- if (readsize == -1)
- perror_msg("%s:%s", applet_name, path);
+ if (readsize == -1) {
+ perror_msg("%s:%s", applet_name, path);
+ return NULL;
+ }
}
while (bufsize < readsize + 1);