summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2009-04-22 19:18:06 +0000
committerjoerg <joerg@pkgsrc.org>2009-04-22 19:18:06 +0000
commit2f723afb55381daaa3795c4ac5ee8e0915f5e314 (patch)
tree1aec51e2aa7fb0590797da853dd38a1de757b259 /pkgtools
parent3f0803ee0ea38c514e134edd95b6bc4e15daf4b2 (diff)
downloadpkgsrc-2f723afb55381daaa3795c4ac5ee8e0915f5e314.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/info/perform.c14
-rw-r--r--pkgtools/pkg_install/files/lib/pkg_signature.c10
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
3 files changed, 16 insertions, 12 deletions
diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c
index de1ac33add8..cdfe5ad6c05 100644
--- a/pkgtools/pkg_install/files/info/perform.c
+++ b/pkgtools/pkg_install/files/info/perform.c
@@ -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>.
@@ -183,8 +183,10 @@ read_meta_data_from_archive(struct archive *archive,
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 @@ has_entry:
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 --git a/pkgtools/pkg_install/files/lib/pkg_signature.c b/pkgtools/pkg_install/files/lib/pkg_signature.c
index fb7aec34787..710482e56a9 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.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>.
@@ -179,9 +179,11 @@ retry:
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 --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 2edea7f38fd..e664698a58b 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.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_ */