From 47d91c5fba6bc90d79503b7c69c6146abb8825f5 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Fri, 15 Aug 2014 10:19:54 -0700 Subject: 33012: add an error return value (-1) to xsymlinks() --- Src/utils.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Src') diff --git a/Src/utils.c b/Src/utils.c index 998e46a36..076a33c0f 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -716,7 +716,6 @@ slashsplit(char *s) } /* expands symlinks and .. or . expressions */ -/* if flag = 0, only expand .. and . expressions */ /**/ static int @@ -753,6 +752,7 @@ xsymlinks(char *s) strcat(xbuf, *pp); } else { *xbuf = 0; + ret = -1; break; } } else { @@ -760,9 +760,11 @@ xsymlinks(char *s) metafy(xbuf3, t0, META_NOALLOC); if (*xbuf3 == '/') { strcpy(xbuf, ""); - xsymlinks(xbuf3 + 1); + if (xsymlinks(xbuf3 + 1) < 0) + ret = -1; } else - xsymlinks(xbuf3); + if (xsymlinks(xbuf3) < 0) + ret = -1; } } freearray(opp); @@ -781,11 +783,10 @@ xsymlink(char *s) if (*s != '/') return NULL; *xbuf = '\0'; - xsymlinks(s + 1); - if (!*xbuf) { + if (xsymlinks(s + 1) < 0) zwarn("path expansion failed, using root directory"); + if (!*xbuf) return ztrdup("/"); - } return ztrdup(xbuf); } @@ -795,7 +796,7 @@ print_if_link(char *s) { if (*s == '/') { *xbuf = '\0'; - if (xsymlinks(s + 1)) + if (xsymlinks(s + 1) > 0) printf(" -> "), zputs(*xbuf ? xbuf : "/", stdout); } } -- cgit 1.4.1