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-20090422:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f684181cc72d
branches:  trunk
changeset: 391952:f684181cc72d
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Apr 22 19:18:06 2009 +0000

description:
pkg_install-20090422:
Consider EOF during signature scan a fatal error. At the very least, the
package is missing the +CONTENTS file at that point. Correctly reset the
entry pointer in that case and make the meta data extraction stricter,
avoiding NULL dereferences for invalid archives.
Fixes pkg_info -X crash on empty files as reported by Daniel Horecki.

diffstat:

 pkgtools/pkg_install/files/info/perform.c      |  14 ++++++++------
 pkgtools/pkg_install/files/lib/pkg_signature.c |  10 ++++++----
 pkgtools/pkg_install/files/lib/version.h       |   4 ++--
 3 files changed, 16 insertions(+), 12 deletions(-)

diffs (96 lines):

diff -r 133d50ac5e18 -r f684181cc72d pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Wed Apr 22 19:14:16 2009 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Wed Apr 22 19:18:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.55 2009/03/09 19:58:45 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.56 2009/04/22 19:18:06 joerg Exp $       */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -13,7 +13,7 @@
 #if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
-__RCSID("$NetBSD: perform.c,v 1.55 2009/03/09 19:58:45 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.56 2009/04/22 19:18:06 joerg Exp $");
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -183,8 +183,10 @@
        meta = xcalloc(1, sizeof(*meta));
 
        last_descr = 0;
-       if (entry != NULL)
+       if (entry != NULL) {
+               r = ARCHIVE_OK;
                goto has_entry;
+       }
 
        while ((r = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
 has_entry:
@@ -228,13 +230,13 @@
                if (descr->required_file)
                        --found_required;
        }
-       if (found_required != 0) {
+
+       meta->is_installed = 0;
+       if (found_required != 0 && r != ARCHIVE_OK && r != ARCHIVE_EOF) {
                free_pkg_meta(meta);
                meta = NULL;
        }
 
-       meta->is_installed = 0;
-
        return meta;
 }
 #endif
diff -r 133d50ac5e18 -r f684181cc72d pkgtools/pkg_install/files/lib/pkg_signature.c
--- a/pkgtools/pkg_install/files/lib/pkg_signature.c    Wed Apr 22 19:14:16 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/pkg_signature.c    Wed Apr 22 19:18:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pkg_signature.c,v 1.7 2009/03/08 14:50:37 joerg Exp $  */
+/*     $NetBSD: pkg_signature.c,v 1.8 2009/04/22 19:18:06 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.7 2009/03/08 14:50:37 joerg Exp $");
+__RCSID("$NetBSD: pkg_signature.c,v 1.8 2009/04/22 19:18:06 joerg Exp $");
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -179,9 +179,11 @@
                if (r == ARCHIVE_FATAL) {
                        warnx("Cannot read from archive: %s",
                            archive_error_string(archive));
-                       return -1;
+               } else {
+                       warnx("Premature end of archive");
                }
-               return 1;
+               *entry = NULL;
+               return -1;
        }
        if (strcmp(archive_entry_pathname(*entry), "//") == 0) {
                archive_read_data_skip(archive);
diff -r 133d50ac5e18 -r f684181cc72d pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Wed Apr 22 19:14:16 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Wed Apr 22 19:18:06 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.122 2009/04/10 04:03:11 reed Exp $       */
+/*     $NetBSD: version.h,v 1.123 2009/04/22 19:18:06 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 "20090410"
+#define PKGTOOLS_VERSION "20090422"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index