pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20090301:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/51278eef4ce2
branches:  trunk
changeset: 555444:51278eef4ce2
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Mon Mar 02 14:59:14 2009 +0000

description:
pkg_install-20090301:
Plug a number of file descriptor leaks.

diffstat:

 pkgtools/pkg_install/files/add/perform.c              |  14 +++++++++-----
 pkgtools/pkg_install/files/lib/pkcs7.c                |   5 +++--
 pkgtools/pkg_install/files/lib/pkg_signature.c        |   8 ++++++--
 pkgtools/pkg_install/files/lib/version.h              |   4 ++--
 pkgtools/pkg_install/files/lib/vulnerabilities-file.c |   6 ++++--
 5 files changed, 24 insertions(+), 13 deletions(-)

diffs (157 lines):

diff -r a3d47229126f -r 51278eef4ce2 pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Mon Mar 02 14:55:05 2009 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Mon Mar 02 14:59:14 2009 +0000
@@ -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@localhost>
@@ -357,6 +357,7 @@
                warnx("package `%s' already recorded as installed",
                      pkg->pkgname);
        }
+       close(fd);
        return 0;
 
 }
@@ -549,6 +550,7 @@
                                warn("Can't write meta data file: %s",
                                    filename);
                                free(filename);
+                               close(fd);
                                return -1;
                        }
                        len -= ret;
@@ -771,12 +773,14 @@
                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 -r a3d47229126f -r 51278eef4ce2 pkgtools/pkg_install/files/lib/pkcs7.c
--- a/pkgtools/pkg_install/files/lib/pkcs7.c    Mon Mar 02 14:55:05 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/pkcs7.c    Mon Mar 02 14:59:14 2009 +0000
@@ -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 @@
                        }
                        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 -r a3d47229126f -r 51278eef4ce2 pkgtools/pkg_install/files/lib/pkg_signature.c
--- a/pkgtools/pkg_install/files/lib/pkg_signature.c    Mon Mar 02 14:55:05 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/pkg_signature.c    Mon Mar 02 14:59:14 2009 +0000
@@ -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@localhost>.
@@ -614,6 +614,8 @@
 
        archive_write_finish(pkg);
 
+       close(fd);
+
        exit(0);
 }
 #endif
@@ -706,5 +708,7 @@
 
        archive_write_finish(pkg);
 
+       close(fd);
+
        exit(0);
 }
diff -r a3d47229126f -r 51278eef4ce2 pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Mon Mar 02 14:55:05 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Mon Mar 02 14:59:14 2009 +0000
@@ -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 -r a3d47229126f -r 51278eef4ce2 pkgtools/pkg_install/files/lib/vulnerabilities-file.c
--- a/pkgtools/pkg_install/files/lib/vulnerabilities-file.c     Mon Mar 02 14:55:05 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/vulnerabilities-file.c     Mon Mar 02 14:59:14 2009 +0000
@@ -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@localhost>.
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index