From 480fb07817fa4b096397cf9ee8484e8ee38822dc Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 30 Jun 2016 10:37:35 -0500 Subject: Use libbuf instead of stack buffer. --- lib/xwrap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/xwrap.c') 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) { -- cgit v1.2.3