diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2015-08-31 11:38:55 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-08-31 11:38:55 -0400 |
commit | 0a281f1a541c210fbf7f1e8712b1e50874a82fb9 (patch) | |
tree | 44fbb5d227a45d9b06c1c56f5c98ca2edfab6f01 | |
parent | e6a306668a5110e59ace562909d9fdd412369656 (diff) | |
download | bfs-0a281f1a541c210fbf7f1e8712b1e50874a82fb9.tar.xz |
bftw: Fix path size of /.
-rw-r--r-- | bftw.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -233,7 +233,11 @@ static DIR *opendirat(int fd, const char *name) { * Will hold the full path to the entry, with a trailing '/'. */ static int dircache_entry_path(dircache_entry *entry, dynstr *path) { - size_t pathlen = entry->nameoff + entry->namelen + 1; + size_t namelen = entry->namelen; + size_t pathlen = entry->nameoff + namelen; + if (namelen > 0 && entry->name[namelen - 1] != '/') { + ++pathlen; + } if (dynstr_grow(path, pathlen) != 0) { return -1; @@ -245,7 +249,7 @@ static int dircache_entry_path(dircache_entry *entry, dynstr *path) { do { char *segment = path->str + entry->nameoff; - size_t namelen = entry->namelen; + namelen = entry->namelen; memcpy(segment, entry->name, namelen); if (namelen > 0 && entry->name[namelen - 1] != '/') { |