diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-07 17:48:28 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-07 17:48:28 +0000 |
commit | 3eadd2688f3d2e58f4de3597960503444168c3a7 (patch) | |
tree | d08439547c9b94e1d0211fb0de91e68fc3180fe4 /libbb | |
parent | 9d7aed830b2943583f3913b739521ab273856135 (diff) | |
download | busybox-w32-3eadd2688f3d2e58f4de3597960503444168c3a7.tar.gz busybox-w32-3eadd2688f3d2e58f4de3597960503444168c3a7.tar.bz2 busybox-w32-3eadd2688f3d2e58f4de3597960503444168c3a7.zip |
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
git-svn-id: svn://busybox.net/trunk/busybox@2551 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xreadlink.c | 9 |
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 @@ | |||
1 | /* | 1 | /* |
2 | * xreadlink.c - safe implementation of readlink | 2 | * xreadlink.c - safe implementation of readlink. |
3 | * Returns a NULL on failure... | ||
3 | */ | 4 | */ |
4 | 5 | ||
5 | #include <stdio.h> | 6 | #include <stdio.h> |
@@ -22,8 +23,10 @@ extern char *xreadlink(const char *path) | |||
22 | do { | 23 | do { |
23 | buf = xrealloc(buf, bufsize += GROWBY); | 24 | buf = xrealloc(buf, bufsize += GROWBY); |
24 | readsize = readlink(path, buf, bufsize); /* 1st try */ | 25 | readsize = readlink(path, buf, bufsize); /* 1st try */ |
25 | if (readsize == -1) | 26 | if (readsize == -1) { |
26 | perror_msg("%s:%s", applet_name, path); | 27 | perror_msg("%s:%s", applet_name, path); |
28 | return NULL; | ||
29 | } | ||
27 | } | 30 | } |
28 | while (bufsize < readsize + 1); | 31 | while (bufsize < readsize + 1); |
29 | 32 | ||