summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2012-04-11 16:42:50 +0200
committerHugo Mills <hugo@carfax.org.uk>2012-06-05 19:56:20 +0100
commit0195702a0963619f833e2286a98251f841e66047 (patch)
tree2309bb8a1021af5f4bbcaff2091ad3185646e2fc /utils.c
parenteda76e46296549517ef3c437c0c6270372bd511d (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.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index ee7fa1b8..7c8c9d3a 100644
--- a/utils.c
+++ b/utils.c
@@ -1021,6 +1021,7 @@ again:
list);
list_del(&pending->list);
closedir(dirp);
+ dirp = NULL;
goto again;
}
ret = 0;