diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-11-21 18:05:36 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-11-21 18:05:36 -0500 |
commit | fae757c2d7ba933b3db3cfae6c871846b4d1870f (patch) | |
tree | 8f3bd18052cbe5e09a8bb8de6724f53c48af621d /bftw.c | |
parent | 9b5342ef493521d42953e5f26ea88b58973c6c6a (diff) | |
download | bfs-fae757c2d7ba933b3db3cfae6c871846b4d1870f.tar.xz |
bftw: Make a defensive copy of the ftwbuf
The callback may modify the ftwbuf, but we check it after the callback
(for typeflag and statbuf). Have them mutate a copy instead.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -841,7 +841,10 @@ static int bftw_handle_path(struct bftw_state *state) { return BFTW_FAIL; } - enum bftw_action action = state->fn(&state->ftwbuf, state->ptr); + // Defensive copy + struct BFTW ftwbuf = state->ftwbuf; + + enum bftw_action action = state->fn(&ftwbuf, state->ptr); switch (action) { case BFTW_CONTINUE: case BFTW_SKIP_SIBLINGS: |