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/info Don't segfault if runn...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f365dccfccca
branches:  trunk
changeset: 554308:f365dccfccca
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Feb 11 23:51:30 2009 +0000

description:
Don't segfault if running pkg_info on a binary package without
+BUILD_INFO (or installed without +INSTALLED_INFO). Second half of
PR 30276.

diffstat:

 pkgtools/pkg_install/files/info/perform.c |  19 +++++++++++++------
 pkgtools/pkg_install/files/info/show.c    |   9 ++++++---
 2 files changed, 19 insertions(+), 9 deletions(-)

diffs (70 lines):

diff -r a1979d002c19 -r f365dccfccca pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Wed Feb 11 23:42:42 2009 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Wed Feb 11 23:51:30 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.49 2009/02/02 12:35:01 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.50 2009/02/11 23:51:30 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.49 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.50 2009/02/11 23:51:30 joerg Exp $");
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -363,10 +363,17 @@
                show_index(meta->meta_comment, tmp);
        } else if (Flags & SHOW_BI_VAR) {
                if (strcspn(BuildInfoVariable, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
-                   == strlen(BuildInfoVariable))
-                       show_var(meta->meta_installed_info, BuildInfoVariable);
-               else
-                       show_var(meta->meta_build_info, BuildInfoVariable);
+                   == strlen(BuildInfoVariable)) {
+                       if (meta->meta_installed_info)
+                               show_var(meta->meta_installed_info, BuildInfoVariable);
+                       else
+                               warnx("Installation information missing");
+               } else {
+                       if (meta->meta_build_info)
+                               show_var(meta->meta_build_info, BuildInfoVariable);
+                       else
+                               warnx("Build information missing");
+               }
        } else {
                package_t plist;
                
diff -r a1979d002c19 -r f365dccfccca pkgtools/pkg_install/files/info/show.c
--- a/pkgtools/pkg_install/files/info/show.c    Wed Feb 11 23:42:42 2009 +0000
+++ b/pkgtools/pkg_install/files/info/show.c    Wed Feb 11 23:51:30 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: show.c,v 1.23 2009/02/02 12:35:01 joerg Exp $  */
+/*     $NetBSD: show.c,v 1.24 2009/02/11 23:51:30 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: show.c,v 1.23 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: show.c,v 1.24 2009/02/11 23:51:30 joerg Exp $");
 
 /*
  * FreeBSD install - a package for the installation and maintainance
@@ -366,7 +366,10 @@
        print_string_as_var("COMMENT", meta->meta_comment);
        print_string_as_var("SIZE_PKG", meta->meta_size_pkg);
 
-       var_copy_list(meta->meta_build_info, bi_vars);
+       if (meta->meta_build_info)
+               var_copy_list(meta->meta_build_info, bi_vars);
+       else
+               warnx("Build information missing");
 
        if (binpkgfile != NULL && stat(binpkgfile, &st) == 0) {
            const char *base;



Home | Main Index | Thread Index | Old Index