diff options
author | bapt <bapt@FreeBSD.org> | 2015-02-11 08:07:32 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-02-11 08:07:32 +0000 |
commit | 1e06417cb0344ba79c156ce70b69e9db1da17e26 (patch) | |
tree | 1070c05e9566b39cd63dd926fdad9aa820d85b44 /usr.sbin/pkg | |
parent | d2a14186aef51ebf64b9fb9c9d6fc8949d4e1917 (diff) | |
download | FreeBSD-src-1e06417cb0344ba79c156ce70b69e9db1da17e26.zip FreeBSD-src-1e06417cb0344ba79c156ce70b69e9db1da17e26.tar.gz |
MFC: r278172
Plug resources leak
CID: 1125813
CID: 1125807
CID: 1125808
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 182c739..dc4f772 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -375,8 +375,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 || @@ -806,8 +809,11 @@ cleanup: close(fd_sig); unlink(tmpsig); } - close(fd_pkg); - unlink(tmppkg); + + if (fd_pkg != -1) { + close(fd_pkg); + unlink(tmppkg); + } return (ret); } @@ -851,7 +857,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) { |