diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-06-06 23:28:03 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-06-06 23:28:03 -0700 |
| commit | 257f8ee0d0a4eeba24e638c74a2ce475c518f3f6 (patch) | |
| tree | 9a7c83e639d3f1ea5c366cb3f0129e89cc0dee22 /bb.c | |
| parent | 9ab3ad0fa01ddb51deace904fe6695a8045fd68f (diff) | |
Fix for top level '/' dir edge cases
Diffstat (limited to 'bb.c')
| -rw-r--r-- | bb.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -744,7 +744,7 @@ entry_t* load_entry(bb_t *bb, const char *path) strcpy(pbuf, bb->path); strcat(pbuf, path); } - if (pbuf[strlen(pbuf)-1] == '/') + if (pbuf[strlen(pbuf)-1] == '/' && pbuf[1]) pbuf[strlen(pbuf)-1] = '\0'; // Check for pre-existing: @@ -768,9 +768,13 @@ entry_t* load_entry(bb_t *bb, const char *path) char *end = stpcpy(entry->fullname, pbuf); if (linkpathlen >= 0) entry->linkname = strcpy(end + 1, linkbuf); - entry->name = strrchr(entry->fullname, '/'); - if (!entry->name) err("No slash found in '%s'", entry->fullname); - ++entry->name; + if (strcmp(entry->fullname, "/") == 0) { + entry->name = entry->fullname; + } else { + entry->name = strrchr(entry->fullname, '/'); + if (!entry->name) err("No slash found in '%s' from '%s'", entry->fullname, path); + ++entry->name; + } if (S_ISLNK(filestat.st_mode)) entry->linkedmode = linkedstat.st_mode; entry->info = filestat; |
