/usr/share/perl5/Protocol/HTTP2/Huffman.pm is in libprotocol-http2-perl 1.08-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | package Protocol::HTTP2::Huffman;
use strict;
use warnings;
use Protocol::HTTP2::HuffmanCodes;
use Protocol::HTTP2::Trace qw(tracer);
our ( %hcodes, %rhcodes, $hre );
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(huffman_encode huffman_decode);
# Memory unefficient algorithm (well suited for short strings)
sub huffman_encode {
my $s = shift;
my $ret = my $bin = '';
for my $i ( 0 .. length($s) - 1 ) {
$bin .= $hcodes{ ord( substr $s, $i, 1 ) };
}
$bin .= substr( $hcodes{256}, 0, 8 - length($bin) % 8 ) if length($bin) % 8;
return $ret . pack( 'B*', $bin );
}
sub huffman_decode {
my $s = shift;
my $bin = unpack( 'B*', $s );
my $c = 0;
$s = pack 'C*', map { $c += length; $rhcodes{$_} } ( $bin =~ /$hre/g );
tracer->warning(
sprintf(
"malformed data in string at position %i, " . " length: %i",
$c, length($bin)
)
) if length($bin) - $c > 8;
tracer->warning(
sprintf "no huffman code 256 at the end of encoded string '%s': %s\n",
substr( $s, 0, 30 ),
substr( $bin, $c )
) if $hcodes{256} !~ /^@{[ substr($bin, $c) ]}/;
return $s;
}
1;
|