[Reproducible-commits] [strip-nondeterminism] 01/01: png: gracefully handle nonconformant PNG files with trailing garbage
Andrew Ayer
agwa at andrewayer.name
Sun Oct 18 02:27:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
agwa-guest pushed a commit to branch master
in repository strip-nondeterminism.
commit 94c17377f15cc3191768b34b898aefc6c6977fb9
Author: Andrew Ayer <agwa at andrewayer.name>
Date: Sat Oct 17 19:25:59 2015 -0700
png: gracefully handle nonconformant PNG files with trailing garbage
Closes: #802057
---
lib/File/StripNondeterminism/handlers/png.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/File/StripNondeterminism/handlers/png.pm b/lib/File/StripNondeterminism/handlers/png.pm
index f0f806e..4b92047 100644
--- a/lib/File/StripNondeterminism/handlers/png.pm
+++ b/lib/File/StripNondeterminism/handlers/png.pm
@@ -72,9 +72,24 @@ sub normalize {
gmtime($canonical_time))) if defined($canonical_time);
} else {
print $tempfile $header . $data;
+
+ last if $type eq 'IEND'; # Stop processing immediately, in case
+ # there's garbage after the PNG datastream.
+ # (see https://bugs.debian.org/802057)
}
}
+ # Copy through trailing garbage. Conformant PNG files don't have trailing
+ # garbage (see http://www.w3.org/TR/PNG/#15FileConformance item c), however
+ # in the interest of strip-nondeterminism being as transparent as possible,
+ # we preserve the garbage.
+ my $bytes_read;
+ my $buf;
+ while ($bytes_read = read($fh, $buf, 4096)) {
+ print $tempfile $buf;
+ }
+ defined($bytes_read) or die "$filename: read failed: $!";
+
chmod((stat($fh))[2] & 07777, $tempfile->filename);
rename($tempfile->filename, $filename)
or die "$filename: unable to overwrite: rename: $!";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/strip-nondeterminism.git
More information about the Reproducible-commits
mailing list