summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPatrick Latifi <pat@cvs.openbsd.org>2005-06-14 03:56:15 +0000
committerPatrick Latifi <pat@cvs.openbsd.org>2005-06-14 03:56:15 +0000
commit425cbe2292bab7c7e0072b156040a407848e3792 (patch)
tree0133d70dd3284a041e590ad33f06d498731b13ec /usr.bin
parent9f795d1f9649555c1fb9a07893e6364d771e8ef4 (diff)
missing closedir() on error path; ok joris xsa
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/util.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 9e5c1af9ee4..0170e6c75d5 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.32 2005/06/02 20:19:30 joris Exp $ */
+/* $OpenBSD: util.c,v 1.33 2005/06/14 03:56:14 pat Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -521,6 +521,7 @@ cvs_exec(int argc, char **argv, int fds[3])
int
cvs_remove_dir(const char *path)
{
+ int ret = -1;
size_t len;
DIR *dirp;
struct dirent *ent;
@@ -537,30 +538,28 @@ cvs_remove_dir(const char *path)
continue;
len = cvs_path_cat(path, ent->d_name, fpath, sizeof(fpath));
- if (len >= sizeof(fpath)) {
- closedir(dirp);
- return (-1);
- }
+ if (len >= sizeof(fpath))
+ goto done;
if (ent->d_type == DT_DIR) {
- if (cvs_remove_dir(fpath) == -1) {
- closedir(dirp);
- return (-1);
- }
+ if (cvs_remove_dir(fpath) == -1)
+ goto done;
} else if ((unlink(fpath) == -1) && (errno != ENOENT)) {
cvs_log(LP_ERRNO, "failed to remove '%s'", fpath);
- return (-1);
+ goto done;
}
}
- closedir(dirp);
if ((rmdir(path) == -1) && (errno != ENOENT)) {
cvs_log(LP_ERRNO, "failed to remove '%s'", path);
- return (-1);
+ goto done;
}
- return (0);
+ ret = 0;
+done:
+ closedir(dirp);
+ return (ret);
}
/*