From 61cf1bf90c94fd19701c644603a39ff98c86a0ea Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 19 Jun 2019 16:45:10 -0700 Subject: Fixed issue with extra '/' appearing in link paths --- bb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bb.c b/bb.c index ec74496..5d6f3cd 100644 --- a/bb.c +++ b/bb.c @@ -733,7 +733,8 @@ entry_t* load_entry(bb_t *bb, const char *path, int clear_dots) if (S_ISLNK(filestat.st_mode)) { linkpathlen = readlink(pbuf, linkbuf, sizeof(linkbuf)); if (linkpathlen < 0) err("Couldn't read link: '%s'", pbuf); - linkbuf[linkpathlen] = 0; + linkbuf[linkpathlen] = '\0'; + while (linkpathlen > 0 && linkbuf[linkpathlen-1] == '/') linkbuf[--linkpathlen] = '\0'; if (stat(pbuf, &linkedstat) == -1) memset(&linkedstat, 0, sizeof(linkedstat)); } size_t pathlen = strlen(pbuf); -- cgit v1.2.3