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
This commit is contained in:
Eric Andersen
2001-05-07 17:48:28 +00:00
parent 822c3837f9
commit 28355a36da
7 changed files with 16 additions and 11 deletions

View File

@@ -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);