aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bb.c3
1 files changed, 2 insertions, 1 deletions
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);