diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-07-08 14:09:27 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-07-08 14:09:27 -0400 |
commit | d24ecd23c4aec43788b61d30dbf78a894626c3c9 (patch) | |
tree | cf43da12fe24203b5ca16e6a439fc5258aab1ed9 | |
parent | 148c5856e4a3f916ec729469e36489f5280602d4 (diff) | |
download | bfs-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.
-rw-r--r-- | bftw.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; |