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/lib Fix segmentation fault ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ff6eefbf6506
branches:  trunk
changeset: 531984:ff6eefbf6506
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu Aug 09 18:03:38 2007 +0000

description:
Fix segmentation fault when the package has no variables set and
no info file. Patch from Dieter Baron in pkg/36741.
Bump version to 20070809 for today's fixes.

diffstat:

 pkgtools/pkg_install/files/lib/var.c     |  23 +++++++++++++++--------
 pkgtools/pkg_install/files/lib/version.h |   4 ++--
 2 files changed, 17 insertions(+), 10 deletions(-)

diffs (80 lines):

diff -r 643f788e6c07 -r ff6eefbf6506 pkgtools/pkg_install/files/lib/var.c
--- a/pkgtools/pkg_install/files/lib/var.c      Thu Aug 09 16:18:15 2007 +0000
+++ b/pkgtools/pkg_install/files/lib/var.c      Thu Aug 09 18:03:38 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.4 2006/04/24 13:52:05 dillo Exp $    */
+/*     $NetBSD: var.c,v 1.5 2007/08/09 18:03:38 joerg Exp $    */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include <sys/cdefs.h>
 #endif
 #ifndef lint
-__RCSID("$NetBSD: var.c,v 1.4 2006/04/24 13:52:05 dillo Exp $");
+__RCSID("$NetBSD: var.c,v 1.5 2007/08/09 18:03:38 joerg Exp $");
 #endif
 
 #if HAVE_SYS_STAT_H
@@ -168,23 +168,29 @@
                return 0;
 
        fp = fopen(fname, "r");
-       if (!fp && errno != ENOENT) {
-               warn("var_set: can't open '%s' for reading", fname);
-               return -1;
+       if (fp == NULL) {
+               if (errno != ENOENT) {
+                       warn("var_set: can't open '%s' for reading", fname);
+                       return -1;
+               }
+               if (value == NULL)
+                       return 0; /* Nothing to do */
        }
 
        tmpname = malloc(strlen(fname)+8);
        sprintf(tmpname, "%s.XXXXXX", fname);
        if ((fd=mkstemp(tmpname)) < 0) {
                free(tmpname);
-               fclose(fp);
+               if (fp != NULL)
+                       fclose(fp);
                warn("var_set: can't open temp file for '%s' for writing",
                      fname);
                return -1;
        }
        if (chmod(tmpname, 0644) < 0) {
                close(fd);
-               fclose(fp);
+               if (fp != NULL)
+                       fclose(fp);
                free(tmpname);
                warn("var_set: can't set permissions for temp file for '%s'",
                      fname);
@@ -194,7 +200,8 @@
                close(fd);
                remove(tmpname);
                free(tmpname);
-               fclose(fp);
+               if (fp != NULL)
+                       fclose(fp);
                warn("var_set: can't open temp file for '%s' for writing",
                      fname);
                return -1;
diff -r 643f788e6c07 -r ff6eefbf6506 pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Thu Aug 09 16:18:15 2007 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Thu Aug 09 18:03:38 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.73 2007/08/08 22:33:40 joerg Exp $       */
+/*     $NetBSD: version.h,v 1.74 2007/08/09 18:03:38 joerg Exp $       */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -33,6 +33,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION "20070808"
+#define PKGTOOLS_VERSION "20070809"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index