diff options
author | Jim Meyering <jim@meyering.net> | 2012-04-11 16:42:50 +0200 |
---|---|---|
committer | Hugo Mills <hugo@carfax.org.uk> | 2012-06-05 19:56:20 +0100 |
commit | 0195702a0963619f833e2286a98251f841e66047 (patch) | |
tree | 2309bb8a1021af5f4bbcaff2091ad3185646e2fc /utils.c | |
parent | eda76e46296549517ef3c437c0c6270372bd511d (diff) |
btrfs_scan_one_dir: avoid use-after-free on error path
If we iterate the "goto again" loop, we've called "closedir(dirp)",
yet at the top of the loop, upon malloc failure we "goto fail",
where we test dirp and if non-NULL, call closedir(dirp) again.
* utils.c (btrfs_scan_one_dir): Clear "dirp" after closedir to avoid
use-after-free upon failed fullpath = malloc(...
Signed-off-by: Jim Meyering <meyering@redhat.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1021,6 +1021,7 @@ again: list); list_del(&pending->list); closedir(dirp); + dirp = NULL; goto again; } ret = 0; |