summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-08 14:09:27 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-08 14:09:27 -0400
commitd24ecd23c4aec43788b61d30dbf78a894626c3c9 (patch)
treecf43da12fe24203b5ca16e6a439fc5258aab1ed9 /bftw.c
parent148c5856e4a3f916ec729469e36489f5280602d4 (diff)
downloadbfs-d24ecd23c4aec43788b61d30dbf78a894626c3c9.tar.xz
Revert "bftw: Don't store the terminating '\0' in dircache_entry names."
This reverts commit 20860becb5a0e89ee2aaaddbb0ba1eb248552640. The terminating NUL will be useful for the upcoming per-component traversal to handle ENAMETOOLONG.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index 1eac4bc..46bcede 100644
--- a/bftw.c
+++ b/bftw.c
@@ -207,7 +207,7 @@ static void dircache_pop(struct dircache *cache, struct dircache_entry *entry) {
/** Add an entry to the dircache. */
static struct dircache_entry *dircache_add(struct dircache *cache, struct dircache_entry *parent, const char *name) {
size_t namelen = strlen(name);
- size_t size = sizeof(struct dircache_entry) + namelen;
+ size_t size = sizeof(struct dircache_entry) + namelen + 1;
bool needs_slash = false;
if (namelen == 0 || name[namelen - 1] != '/') {
@@ -241,6 +241,7 @@ static struct dircache_entry *dircache_add(struct dircache *cache, struct dircac
if (needs_slash) {
entry->name[namelen++] = '/';
}
+ entry->name[namelen] = '\0';
entry->namelen = namelen;
return entry;