summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install
diff options
context:
space:
mode:
authorjoerg <joerg>2009-03-02 14:59:14 +0000
committerjoerg <joerg>2009-03-02 14:59:14 +0000
commit91da527344a07ea356d7119bceec04773d480a44 (patch)
treed397379985b081cf44a009b11652967c27c9c0e2 /pkgtools/pkg_install
parente5a2c65e719a5131c739e1379154aa0a90780259 (diff)
downloadpkgsrc-91da527344a07ea356d7119bceec04773d480a44.tar.gz
pkg_install-20090301:
Plug a number of file descriptor leaks.
Diffstat (limited to 'pkgtools/pkg_install')
-rw-r--r--pkgtools/pkg_install/files/add/perform.c14
-rw-r--r--pkgtools/pkg_install/files/lib/pkcs7.c5
-rw-r--r--pkgtools/pkg_install/files/lib/pkg_signature.c8
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
-rw-r--r--pkgtools/pkg_install/files/lib/vulnerabilities-file.c6
5 files changed, 24 insertions, 13 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
index 0111edbd9e2..9aa37689cf2 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.81 2009/02/28 16:03:56 joerg Exp $ */
+/* $NetBSD: perform.c,v 1.82 2009/03/02 14:59:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
@@ -6,7 +6,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: perform.c,v 1.81 2009/02/28 16:03:56 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.82 2009/03/02 14:59:14 joerg Exp $");
/*-
* Copyright (c) 2003 Grant Beattie <grant@NetBSD.org>
@@ -357,6 +357,7 @@ check_already_installed(struct pkg_task *pkg)
warnx("package `%s' already recorded as installed",
pkg->pkgname);
}
+ close(fd);
return 0;
}
@@ -549,6 +550,7 @@ write_meta_data(struct pkg_task *pkg)
warn("Can't write meta data file: %s",
filename);
free(filename);
+ close(fd);
return -1;
}
len -= ret;
@@ -771,12 +773,14 @@ pkg_register_depends(struct pkg_task *pkg)
required_by = pkgdb_pkg_file(pkg->dependencies[i], REQUIRED_BY_FNAME);
fd = open(required_by, O_WRONLY | O_APPEND | O_CREAT, 0644);
- if (fd == -1)
+ if (fd == -1) {
warn("can't open dependency file '%s',"
"registration is incomplete!", required_by);
- else if (write(fd, text, text_len) != text_len)
+ close(fd);
+ } else if (write(fd, text, text_len) != text_len) {
warn("can't write to dependency file `%s'", required_by);
- else if (close(fd) == -1)
+ close(fd);
+ } else if (close(fd) == -1)
warn("cannot close file %s", required_by);
free(required_by);
diff --git a/pkgtools/pkg_install/files/lib/pkcs7.c b/pkgtools/pkg_install/files/lib/pkcs7.c
index 086dc8d463a..6ebe4ebe578 100644
--- a/pkgtools/pkg_install/files/lib/pkcs7.c
+++ b/pkgtools/pkg_install/files/lib/pkcs7.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pkcs7.c,v 1.3 2009/02/16 20:59:11 joerg Exp $ */
+/* $NetBSD: pkcs7.c,v 1.4 2009/03/02 14:59:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
@@ -7,7 +7,7 @@
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: pkcs7.c,v 1.3 2009/02/16 20:59:11 joerg Exp $");
+__RCSID("$NetBSD: pkcs7.c,v 1.4 2009/03/02 14:59:14 joerg Exp $");
/*-
* Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
@@ -105,6 +105,7 @@ file_to_certs(const char *file)
}
sk_X509_free(certs);
warnx("Can't read certificate in file: %s", file);
+ fclose(f);
return NULL;
}
sk_X509_insert(certs, cert, sk_X509_num(certs));
diff --git a/pkgtools/pkg_install/files/lib/pkg_signature.c b/pkgtools/pkg_install/files/lib/pkg_signature.c
index bcac9b08ed1..b270619a892 100644
--- a/pkgtools/pkg_install/files/lib/pkg_signature.c
+++ b/pkgtools/pkg_install/files/lib/pkg_signature.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pkg_signature.c,v 1.5 2009/02/13 13:17:41 joerg Exp $ */
+/* $NetBSD: pkg_signature.c,v 1.6 2009/03/02 14:59:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: pkg_signature.c,v 1.5 2009/02/13 13:17:41 joerg Exp $");
+__RCSID("$NetBSD: pkg_signature.c,v 1.6 2009/03/02 14:59:14 joerg Exp $");
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -614,6 +614,8 @@ pkg_sign_x509(const char *name, const char *output, const char *key_file, const
archive_write_finish(pkg);
+ close(fd);
+
exit(0);
}
#endif
@@ -706,5 +708,7 @@ pkg_sign_gpg(const char *name, const char *output)
archive_write_finish(pkg);
+ close(fd);
+
exit(0);
}
diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 819d9ac24a0..56b682760fb 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.115 2009/02/28 16:03:56 joerg Exp $ */
+/* $NetBSD: version.h,v 1.116 2009/03/02 14:59:14 joerg Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@@ -27,6 +27,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
-#define PKGTOOLS_VERSION "20090228"
+#define PKGTOOLS_VERSION "20090301"
#endif /* _INST_LIB_VERSION_H_ */
diff --git a/pkgtools/pkg_install/files/lib/vulnerabilities-file.c b/pkgtools/pkg_install/files/lib/vulnerabilities-file.c
index aca293bb5f5..a53f73466ff 100644
--- a/pkgtools/pkg_install/files/lib/vulnerabilities-file.c
+++ b/pkgtools/pkg_install/files/lib/vulnerabilities-file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vulnerabilities-file.c,v 1.4 2009/02/02 12:35:01 joerg Exp $ */
+/* $NetBSD: vulnerabilities-file.c,v 1.5 2009/03/02 14:59:14 joerg Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -38,7 +38,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: vulnerabilities-file.c,v 1.4 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: vulnerabilities-file.c,v 1.5 2009/03/02 14:59:14 joerg Exp $");
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -368,6 +368,8 @@ read_pkg_vulnerabilities(const char *path, int ignore_missing, int check_sum)
if (bytes_read != st.st_size)
errx(1, "Unexpected short read");
+ close(fd);
+
if (decompress_buffer(input, input_len, &decompressed_input,
&decompressed_len)) {
free(input);