[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.4.3-126-gdd2ecf1



The following commit has been merged in the master branch:
commit dd2ecf14372bdad50c6e27f095ec1b561be2d159
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Jan 16 14:06:54 2011 +0100

    Check return value of close and unlink in collections
    
    A number of collections did not check the return value of close
    on a write handle.  This could lead a collection to succeed even
    if it failed to collect the data it was supposed to.  Return value
    of close on a read handle is still (usually) ignored.
      The same thing was done for unlink to ensure that files/symlinks
    are really unlinked.

diff --git a/collection/ar-info b/collection/ar-info
index 01c167e..f33f12e 100755
--- a/collection/ar-info
+++ b/collection/ar-info
@@ -38,7 +38,8 @@ chdir("unpacked")
 
 open(INDEX, '<', "../index")
     or fail("cannot open index file: $!");
-open(OUT, '>', "../ar-info");
+open(OUT, '>', "../ar-info")
+    or fail("cannot open ar-info file: $!");
 
 while (<INDEX>) {
     chomp;
@@ -58,4 +59,4 @@ while (<INDEX>) {
 }
 
 close(INDEX);
-close(OUT);
+close(OUT) or fail("cannot write ar-info: $!");
diff --git a/collection/changelog-file b/collection/changelog-file
index 49d5f8e..a553761 100755
--- a/collection/changelog-file
+++ b/collection/changelog-file
@@ -30,7 +30,8 @@ my $type = shift;
 
 -f "fields/package" or fail("changelog-file invoked in wrong directory");
 
-unlink("changelog");
+unlink("changelog") or fail("cannot remove changelog file: $!")
+    if ( -e 'changelog' or -l 'changelog');
 
 # Pick the first of these files that exists.
 my @changelogs = ("unpacked/usr/share/doc/$pkg/changelog.Debian.gz",
@@ -85,7 +86,7 @@ if (not defined $chl) {
     open (COPY, '>', 'changelog') or fail("cannot create changelog: $!");
     print COPY while <CHL>;
     close CHL;
-    close COPY;
+    close (COPY) or fail("cannot write changelog: $!");
 } else {
     link($chl, "changelog")
 	or fail("cannot link $chl to changelog: $!");
@@ -93,7 +94,8 @@ if (not defined $chl) {
 
 # Extract NEWS.Debian files as well, with similar precautious.  Ignore any
 # symlinks to other packages here; in that case, we just won't check the file.
-unlink('NEWS.Debian');
+unlink('NEWS.Debian') or fail("cannot unlink NEWS.Debian: $!")
+    if (-e 'NEWS.Debian' or -l 'NEWS.Debian');
 my $news = "unpacked/usr/share/doc/$pkg/NEWS.Debian.gz";
 if (-f $news) {
     if (-l $news) {
diff --git a/collection/diffstat b/collection/diffstat
index 9fe66ae..40ca984 100755
--- a/collection/diffstat
+++ b/collection/diffstat
@@ -39,7 +39,8 @@ open (V, '<', "fields/version") or fail("cannot open fields/version: $!");
 my $ver = <V>; chomp $ver;
 close V;
 
-unlink('debian-patch');
+unlink('debian-patch') or fail("cannot unlink debian-patch: $!")
+    if( -e 'debian-patch' or -l 'debian-patch');
 
 $ver =~ s/^\d://; #Remove epoch for this
 
diff --git a/collection/file-info b/collection/file-info
index c152f42..593f2e0 100755
--- a/collection/file-info
+++ b/collection/file-info
@@ -56,7 +56,7 @@ while (<INDEX>) {
     s/\\\\/\\/;
     printf {$opts{pipe_in}} "%s\0", $_;
 }
-close(INDEX);
+close(INDEX) or fail("cannot close index file: $!");
 
 close $opts{pipe_in};
 reap(\%opts);
diff --git a/collection/objdump-info b/collection/objdump-info
index 3e15c88..7b3e663 100755
--- a/collection/objdump-info
+++ b/collection/objdump-info
@@ -223,7 +223,7 @@ while (<FILES>) {
 }
 
 close FILES;
-close OUT;
+close OUT or fail("cannot write objdump-info: $!");
 
 exit $failed;
 
diff --git a/collection/scripts b/collection/scripts
index 6ae5796..cfe228c 100755
--- a/collection/scripts
+++ b/collection/scripts
@@ -64,7 +64,7 @@ while (<INDEX>) {
     close(FILE);
 }
 close(INDEX);
-close(SCRIPTS);
+close(SCRIPTS) or fail("cannot write scripts file: $!");
 
 open(SCRIPTS, '>', "control-scripts")
     or fail("cannot open control-scripts output file: $!");
@@ -83,7 +83,7 @@ for $file (readdir CONTROL) {
     close(FILE);
 }
 closedir(CONTROL);
-close(SCRIPTS);
+close(SCRIPTS) or fail("cannot write control-scripts file: $!");
 
 exit 0;
 
diff --git a/collection/source-control-file b/collection/source-control-file
index 8646232..619f9cb 100755
--- a/collection/source-control-file
+++ b/collection/source-control-file
@@ -52,6 +52,6 @@ foreach (@control_data) {
         open (F, '>', "$field_file")
             or fail("cannot open file $field_file for writing: $!");
         print F $value,"\n";
-        close F;
+        close F or fail("cannot write control/$pkg_name/$field: $!");
     }
 }
diff --git a/collection/strings b/collection/strings
index 5a6a906..29e7b86 100755
--- a/collection/strings
+++ b/collection/strings
@@ -58,5 +58,5 @@ while (<FILE_INFO>) {
     spawn({out => "strings/$bin", fail => 'error'}, ['strings', "unpacked/$bin"]);
 }
 
-close(ELF_INDEX);
+close(ELF_INDEX) or fail("cannot write elf-index file: $!");
 close(FILE_INFO);

-- 
Debian package checker


Reply to: