Prechádzať zdrojové kódy

libdpkg: Do not try to close already closed files

Guillem Jover 17 rokov pred
rodič
commit
d30fdccff5
2 zmenil súbory, kde vykonal 10 pridanie a 2 odobranie
  1. 1 0
      debian/changelog
  2. 9 2
      lib/triglib.c

+ 1 - 0
debian/changelog

@@ -5,6 +5,7 @@ dpkg (1.15.3) UNRELEASED; urgency=low
   * Use default compressor values in dpkg-source from Dpkg::Source::Compressor.
   * Fix dpkg-scanpackages to properly detect spurious overrides.
   * Rewrite dpkg-name in perl.
+  * Do not close already closed files in some error conditions in libdpkg.
 
   [ Raphael Hertzog ]
   * Unset TAR_OPTIONS when creating/extracting tar archives for source

+ 9 - 2
lib/triglib.c

@@ -404,10 +404,14 @@ trk_explicit_interest_change(const char *trig,  struct pkginfo *pkg, int signum)
 	}
 	if (signum > 0)
 		fprintf(nf, "%s\n", pkg->name);
-	if (ferror(nf) || fclose(nf))
+
+	if (ferror(nf))
 		ohshite(_("unable to write new trigger interest file `%.250s'"),
 		        newfn.buf);
 	pop_cleanup(ehflag_normaltidy);
+	if (fclose(nf))
+		ohshite(_("unable to close new trigger interest file `%.250s'"),
+		        newfn.buf);
 
 	if (rename(newfn.buf, trk_explicit_fn.buf))
 		ohshite(_("unable to install new trigger interest file `%.250s'"),
@@ -498,10 +502,13 @@ trig_file_interests_save(void)
 		fprintf(nf, "%s %s\n", trigh.namenode_name(tfi->fnn),
 		        tfi->pkg->name);
 
-	if (ferror(nf) || fclose(nf))
+	if (ferror(nf))
 		ohshite(_("unable to write new file triggers file `%.250s'"),
 		        triggersnewfilefile);
 	pop_cleanup(ehflag_normaltidy);
+	if (fclose(nf))
+		ohshite(_("unable to close new file triggers file `%.250s'"),
+		        triggersnewfilefile);
 
 	if (rename(triggersnewfilefile, triggersfilefile))
 		ohshite(_("unable to install new file triggers file as `%.250s'"),