diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-02-04 00:10:57 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-02-04 00:10:57 +0000 |
commit | 92947daacfb681797cd651a77b8c8d6cab3b8487 (patch) | |
tree | 7826acb0560f4c2a65c9cad0b3359a45cdeb09f3 /usr.sbin/pkg | |
parent | 3ccccdc17dc8a9f4de900a7eeabf7bd77174225d (diff) | |
download | src-92947daacfb681797cd651a77b8c8d6cab3b8487.tar.gz src-92947daacfb681797cd651a77b8c8d6cab3b8487.zip |
Plug resources leak
CID: 1125813
CID: 1125807
CID: 1125808
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=278172
Diffstat (limited to 'usr.sbin/pkg')
-rw-r--r-- | usr.sbin/pkg/pkg.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 8f26c611e016..e447c9c59377 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -371,8 +371,11 @@ load_fingerprints(const char *path, int *count) return (NULL); STAILQ_INIT(fingerprints); - if ((d = opendir(path)) == NULL) + if ((d = opendir(path)) == NULL) { + free(fingerprints); + return (NULL); + } while ((ent = readdir(d))) { if (strcmp(ent->d_name, ".") == 0 || @@ -799,8 +802,11 @@ cleanup: close(fd_sig); unlink(tmpsig); } - close(fd_pkg); - unlink(tmppkg); + + if (fd_pkg != -1) { + close(fd_pkg); + unlink(tmppkg); + } return (ret); } @@ -849,7 +855,7 @@ bootstrap_pkg_local(const char *pkgpath, bool force) if (config_string(SIGNATURE_TYPE, &signature_type) != 0) { warnx("Error looking up SIGNATURE_TYPE"); - return (-1); + goto cleanup; } if (signature_type != NULL && strcasecmp(signature_type, "FINGERPRINTS") == 0) { |