diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-11-21 17:35:27 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-11-21 17:35:27 -0500 |
commit | 9b5342ef493521d42953e5f26ea88b58973c6c6a (patch) | |
tree | 8e7a60c24f27ecc2e7f9ddafbf5f326c791f35ea /bftw.c | |
parent | 40df4d3d4d6389fbec579e555e79e0ca577e342a (diff) | |
download | bfs-9b5342ef493521d42953e5f26ea88b58973c6c6a.tar.xz |
bftw: Always initialize dircache_entry::{dev,ino}
If stat() fails, they won't get filled in otherwise. Then cycle
detection would have read uninitialized values.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -222,6 +222,9 @@ static struct dircache_entry *dircache_add(struct dircache *cache, struct dircac entry->refcount = 1; entry->fd = -1; + entry->dev = -1; + entry->ino = -1; + memcpy(entry->name, name, namelen); if (needs_slash) { entry->name[namelen++] = '/'; @@ -861,12 +864,10 @@ static struct dircache_entry *bftw_add(struct bftw_state *state, const char *nam return NULL; } - if (state->flags & (BFTW_DETECT_CYCLES | BFTW_XDEV)) { - const struct stat *statbuf = state->ftwbuf.statbuf; - if (statbuf) { - entry->dev = statbuf->st_dev; - entry->ino = statbuf->st_ino; - } + const struct stat *statbuf = state->ftwbuf.statbuf; + if (statbuf) { + entry->dev = statbuf->st_dev; + entry->ino = statbuf->st_ino; } return entry; |