Control: tags -1 patch

Hi,

I believe the two attached patches should fix this.

Thanks,
James
From a69dbdf8400328683259c607bafeb611cfbb94ab Mon Sep 17 00:00:00 2001
From: James Cowgill <[email protected]>
Date: Sun, 24 Jul 2016 11:53:50 +0100
Subject: [PATCH 1/2] Remove temporary PNG file if nothing was changed

---
 lib/File/StripNondeterminism/handlers/png.pm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/File/StripNondeterminism/handlers/png.pm b/lib/File/StripNondeterminism/handlers/png.pm
index a76e304..3c9ed9a 100644
--- a/lib/File/StripNondeterminism/handlers/png.pm
+++ b/lib/File/StripNondeterminism/handlers/png.pm
@@ -59,10 +59,9 @@ sub normalize {
 		chmod((stat($fh))[2] & 07777, $tempfile->filename);
 		rename($tempfile->filename, $filename)
 			or die "$filename: unable to overwrite: rename: $!";
+		$tempfile->unlink_on_destroy(0);
 	}
 
-	$tempfile->unlink_on_destroy(0);
-
 	close $fh;
 }
 
-- 
2.8.1

From eb6fb5ae58c41418b9a4bd30771cb9246ae18ba0 Mon Sep 17 00:00:00 2001
From: James Cowgill <[email protected]>
Date: Sun, 24 Jul 2016 11:54:00 +0100
Subject: [PATCH 2/2] Correctly handle short PNG chunks which are not changed

---
 lib/File/StripNondeterminism/handlers/png.pm | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/File/StripNondeterminism/handlers/png.pm b/lib/File/StripNondeterminism/handlers/png.pm
index 3c9ed9a..4a54da9 100644
--- a/lib/File/StripNondeterminism/handlers/png.pm
+++ b/lib/File/StripNondeterminism/handlers/png.pm
@@ -105,24 +105,26 @@ sub _normalize {
 								gmtime($canonical_time))) if defined($canonical_time);
 				$changed = 1;
 				next;
+			} else {
+				print $tempfile $header . $data;
 			}
-		}
+		} else {
+			print $tempfile $header;
 
-		print $tempfile $header;
+			while ($len > 0) {
+				# Can't trust $len so read data part in chunks
+				$bytes_read = read($fh, $buf, min($len, 4096));
 
-		while ($len > 0) {
-			# Can't trust $len so read data part in chunks
-			$bytes_read = read($fh, $buf, min($len, 4096));
+				if ($bytes_read == 0) {
+					warn "$filename: invalid length in $type header";
+					return 0;
+				}
 
-			if ($bytes_read == 0) {
-				warn "$filename: invalid length in $type header";
-				return 0;
+				print $tempfile $buf;
+				$len -= $bytes_read;
 			}
-
-			print $tempfile $buf;
-			$len -= $bytes_read;
+			defined($bytes_read) or die "$filename: read failed: $!";
 		}
-		defined($bytes_read) or die "$filename: read failed: $!";
 
 		# Stop processing immediately in case there's garbage after the
 		# PNG datastream. (https://bugs.debian.org/802057)
-- 
2.8.1

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to