text
stringlengths
0
234
Td : P_Table_List; -- distance code table
Bl, Bd : Integer; -- lookup bits for tl/bd
Huft_Incomplete : Boolean;
begin
-- Make a complete, but wrong [why ?] code set (see Appnote: 5.5.2, RFC 1951: 3.2.6)
Bl := 7;
Huft_Build
(Length_List_For_Fixed_Block_Literals,
257,
Copy_Lengths_Literal,
Extra_Bits_Literal,
Tl,
Bl,
Huft_Incomplete);
-- Make an incomplete code set (see Appnote: 5.5.2, RFC 1951: 3.2.6)
Bd := 5;
begin
Huft_Build
((0 .. Max_Dist => 5),
0,
Copy_Offset_Distance,
Extra_Bits_Distance,
Td,
Bd,
Huft_Incomplete);
exception
when Huft_Out_Of_Memory | Huft_Error =>
Huft_Free (Tl);
raise Zip.Archive_Corrupted;
Function Definition: procedure Inflate_Dynamic_Block is
Function Body: Lbits : constant := 9;
Dbits : constant := 6;
Current_Length : Natural;
Defined, Number_Of_Lengths : Natural;
Tl : P_Table_List; -- literal/length code tables
Td : P_Table_List; -- distance code tables
Ct : P_Huft_Table; -- current table
Ct_Idx : Natural; -- current table's index
Bl, Bd : Integer; -- lookup bits for tl/bd
Nb : Natural; -- number of bit length codes
Nl : Natural; -- number of literal length codes
Nd : Natural; -- number of distance codes
-- literal/length and distance code lengths
Ll : Length_Array (0 .. 288 + 32 - 1) := (others => 0);
Huft_Incomplete : Boolean;
procedure Repeat_Length_Code (Amount : Natural) is
begin
if Defined + Amount > Number_Of_Lengths then
raise Zip.Archive_Corrupted;
end if;
for C in reverse 1 .. Amount loop
Ll (Defined) := Current_Length;
Defined := Defined + 1;
end loop;
end Repeat_Length_Code;
begin
-- Read in table lengths
Nl := 257 + Unz_Io.Bit_Buffer.Read_And_Dump (5);
Nd := 1 + Unz_Io.Bit_Buffer.Read_And_Dump (5);
Nb := 4 + Unz_Io.Bit_Buffer.Read_And_Dump (4);
if Nl > 288 or else Nd > 32 then
raise Zip.Archive_Corrupted;
end if;
-- Read in bit-length-code lengths for decoding the compression structure.
-- The rest, Ll( Bit_Order( Nb .. 18 ) ), is already = 0
for J in 0 .. Nb - 1 loop
Ll (Bit_Order_For_Dynamic_Block (J)) := Unz_Io.Bit_Buffer.Read_And_Dump (3);
end loop;
-- Build decoding table for trees--single level, 7 bit lookup
Bl := 7;
begin
Huft_Build (Ll (0 .. 18), 19, Empty, Empty, Tl, Bl, Huft_Incomplete);
if Huft_Incomplete then
Huft_Free (Tl);
raise Zip.Archive_Corrupted with
"Incomplete code set for compression structure";
end if;
exception
when Zip.Archive_Corrupted =>
raise;
when others =>
raise Zip.Archive_Corrupted with
"Error when building tables for compression structure";
Function Definition: procedure Inflate is
Function Body: Is_Last_Block : Boolean;
Blocks, Blocks_Fix, Blocks_Dyn : Long_Integer := 0;
begin