Control: retitle -1 libplack-middleware-deflater-perl: broken on big endian 
hosts
Control: reassign -1 libplack-middleware-deflater-perl 0.12-1
Control: tag -1 patch
Control: affects -1 libfurl-perl

On Mon, Mar 19, 2018 at 09:35:03PM +0200, Niko Tyni wrote:

> I got as far as seeing that removing line 144 in Deflater.pm
> 
>  
> https://sources.debian.org/src/libplack-middleware-deflater-perl/0.12-1/lib/Plack/Middleware/Deflater.pm/#L144
> 
> -       $buf .= pack("LL", $self->{crc},$self->{length}) if $self->{encoding} 
> eq 'gzip';
> 
> makes both test suites pass, but that doesn't seem like a fully
> satisfactory patch. (And no, s/LL/NN/ doesn't fix it.)

Hum, this is somewhat embarrassing. s/LL/VV/ does seem to fix it, which
makes sense as L and N are equivalent on big-endian while L and V are
equivalent on little-endian. I blame lack of sleep.

Also, RFC 1952 says

      All multi-byte numbers in the format described here are stored
      with the least-significant byte first (at the lower memory address).

so little endian seems to be correct.

Lightly tested patch attached; reassigning.
-- 
Niko
>From 480e68c781ddad1e5a19446c13134c8fde2a34e8 Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Tue, 20 Mar 2018 21:51:49 +0200
Subject: [PATCH] Fix gzip trailer on big endian hosts

These values need to be stored as little endian regardless
of the host endianness.

Bug-Debian: https://bugs.debian.org/893472
---
 lib/Plack/Middleware/Deflater.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Plack/Middleware/Deflater.pm b/lib/Plack/Middleware/Deflater.pm
index 4cb0b03..c823c38 100644
--- a/lib/Plack/Middleware/Deflater.pm
+++ b/lib/Plack/Middleware/Deflater.pm
@@ -141,7 +141,7 @@ sub print : method {
         if ( !$self->{header} && $self->{encoding} eq 'gzip' ) {
             $buf = pack("nccVcc",GZIP_MAGIC,Z_DEFLATED,0,time(),0,$Compress::Raw::Zlib::gzip_os_code) . $buf
         }
-        $buf .= pack("LL", $self->{crc},$self->{length}) if $self->{encoding} eq 'gzip';
+        $buf .= pack("VV", $self->{crc},$self->{length}) if $self->{encoding} eq 'gzip';
         $self->{closed} = 1;
         return $buf;
     }
-- 
2.16.2

Reply via email to