pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/36741
The following reply was made to PR pkg/36741; it has been noted by GNATS.
From: Dieter Baron <dillo%NetBSD.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: pkg/36741
Date: Wed, 8 Aug 2007 08:44:49 +0200
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
hi,
try the appached diff, which should fix the spurious warning. It also
fixes a segfault if opening the temp file doesn't work and no
+INSTALLED_INFO exists (e.g. when trying to set the first variable as
non-root).
Joerg: okay to commit?
yours,
dillo
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pkg_install-unset.diff"
Index: files/lib/var.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/var.c,v
retrieving revision 1.4
diff -u -r1.4 var.c
--- files/lib/var.c 24 Apr 2006 13:52:05 -0000 1.4
+++ files/lib/var.c 8 Aug 2007 06:40:35 -0000
@@ -168,23 +168,31 @@
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) {
+ /* no variables are set, so unset is a no-op */
+ return 0;
+ }
}
tmpname = malloc(strlen(fname)+8);
sprintf(tmpname, "%s.XXXXXX", fname);
if ((fd=mkstemp(tmpname)) < 0) {
free(tmpname);
- fclose(fp);
+ if (fp)
+ 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)
+ fclose(fp);
free(tmpname);
warn("var_set: can't set permissions for temp file for '%s'",
fname);
@@ -194,7 +202,8 @@
close(fd);
remove(tmpname);
free(tmpname);
- fclose(fp);
+ if (fp)
+ fclose(fp);
warn("var_set: can't open temp file for '%s' for writing",
fname);
return -1;
--UlVJffcvxoiEqYs2--
Home |
Main Index |
Thread Index |
Old Index