diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-06-03 18:50:42 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-14 16:54:30 -0400 |
commit | 1003dcd7681511c5b703e6723e207cdd50d82885 (patch) | |
tree | 7a01c17141231364dc2fe70a14c7e620d5175527 /src/tools | |
parent | db96a910dc72eccaae5fb6b8bc16b31fdd56fdf5 (diff) | |
download | sssd-1003dcd7681511c5b703e6723e207cdd50d82885.tar.gz sssd-1003dcd7681511c5b703e6723e207cdd50d82885.tar.bz2 sssd-1003dcd7681511c5b703e6723e207cdd50d82885.zip |
Fix potential resource leak in copy_tree_ctx()
Ticket #515
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/files.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/files.c b/src/tools/files.c index 27ebf72d..3d45679d 100644 --- a/src/tools/files.c +++ b/src/tools/files.c @@ -603,8 +603,8 @@ static int copy_tree_ctx(struct copy_ctx *cctx, uid_t uid, gid_t gid) { - DIR *src_dir; - int ret; + DIR *src_dir = NULL; + int ret, err; struct dirent *result; struct dirent direntp; char *src_name, *dst_name; @@ -651,12 +651,20 @@ static int copy_tree_ctx(struct copy_ctx *cctx, } ret = closedir(src_dir); + src_dir = NULL; if (ret != 0) { ret = errno; goto fail; } + ret = EOK; fail: + if (src_dir) { /* clean up on abnormal exit but retain return code */ + err = closedir(src_dir); + if (err) { + DEBUG(1, ("closedir failed, bad dirp?\n")); + } + } talloc_free(tmp_ctx); return ret; } |