From d24ecd23c4aec43788b61d30dbf78a894626c3c9 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 8 Jul 2017 14:09:27 -0400 Subject: 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. --- bftw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bftw.c') 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; -- cgit v1.2.3