aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-30 10:37:35 -0500
committerRob Landley <rob@landley.net>2016-06-30 10:37:35 -0500
commit480fb07817fa4b096397cf9ee8484e8ee38822dc (patch)
treec7d3f366c713011c7bab689d9cd08282f6935781
parentcf77fe9d0ef7d37edac01d439e2b14abe5fc6d89 (diff)
downloadtoybox-480fb07817fa4b096397cf9ee8484e8ee38822dc.tar.gz
Use libbuf instead of stack buffer.
-rw-r--r--lib/xwrap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 36a601c5..7176aae1 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -419,7 +419,7 @@ char *xabspath(char *path, int exact)
{
struct string_list *todo, *done = 0;
int try = 9999, dirfd = open("/", 0);;
- char buf[4096], *ret;
+ char *ret;
// If this isn't an absolute path, start with cwd.
if (*path != '/') {
@@ -450,7 +450,7 @@ char *xabspath(char *path, int exact)
} else continue;
// Is this a symlink?
- } else len=readlinkat(dirfd, new->str, buf, 4096);
+ } else len = readlinkat(dirfd, new->str, libbuf, sizeof(libbuf));
if (len>4095) goto error;
if (len<1) {
@@ -474,8 +474,8 @@ char *xabspath(char *path, int exact)
}
// If this symlink is to an absolute path, discard existing resolved path
- buf[len] = 0;
- if (*buf == '/') {
+ libbuf[len] = 0;
+ if (*libbuf == '/') {
llist_traverse(done, free);
done=0;
close(dirfd);
@@ -484,7 +484,7 @@ char *xabspath(char *path, int exact)
free(new);
// prepend components of new path. Note symlink to "/" will leave new NULL
- tail = splitpath(buf, &new);
+ tail = splitpath(libbuf, &new);
// symlink to "/" will return null and leave tail alone
if (new) {