summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoerg <joerg>2007-08-09 18:03:38 +0000
committerjoerg <joerg>2007-08-09 18:03:38 +0000
commit1bc6176ce4a977d4547e64bfe5c164c91e83053a (patch)
tree9cf389df559623c836dba844da55c8c9846a0ce9
parent263211e0cf17758e208c2d3406b76eba8a1ddd01 (diff)
downloadpkgsrc-1bc6176ce4a977d4547e64bfe5c164c91e83053a.tar.gz
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.
-rw-r--r--pkgtools/pkg_install/files/lib/var.c23
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
2 files changed, 17 insertions, 10 deletions
diff --git a/pkgtools/pkg_install/files/lib/var.c b/pkgtools/pkg_install/files/lib/var.c
index 6945af32396..4dc2cc6476b 100644
--- a/pkgtools/pkg_install/files/lib/var.c
+++ b/pkgtools/pkg_install/files/lib/var.c
@@ -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 @@ var_set(const char *fname, const char *variable, const char *value)
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 @@ var_set(const char *fname, const char *variable, const char *value)
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 --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index d835ba0e46f..725a6debcc7 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.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_ */