From 166ede1642869f46a0aae2df885772f7383e9ab2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 23 Jan 2024 06:31:44 +0100 Subject: Adding upstream version 1.24. Signed-off-by: Daniel Baumann --- decoder.cc | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'decoder.cc') diff --git a/decoder.cc b/decoder.cc index fc617de..4c68355 100644 --- a/decoder.cc +++ b/decoder.cc @@ -1,5 +1,5 @@ /* Lziprecover - Data recovery tool for the lzip format - Copyright (C) 2009-2023 Antonio Diaz Diaz. + Copyright (C) 2009-2024 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,21 +112,17 @@ int LZ_decoder::check_trailer( const Pretty_print & pp, const bool ignore_empty ) const { Lzip_trailer trailer; - int size = rdec.read_data( trailer.data, Lzip_trailer::size ); - const unsigned long long data_size = data_position(); - const unsigned long long member_size = rdec.member_position(); + int size = rdec.read_data( trailer.data, trailer.size ); bool error = false; - if( size < Lzip_trailer::size ) + if( size < trailer.size ) { error = true; if( verbosity >= 0 ) - { - pp(); - std::fprintf( stderr, "Trailer truncated at trailer position %d;" - " some checks may fail.\n", size ); - } - while( size < Lzip_trailer::size ) trailer.data[size++] = 0; + { pp(); + std::fprintf( stderr, "Trailer truncated at trailer position %d;" + " some checks may fail.\n", size ); } + while( size < trailer.size ) trailer.data[size++] = 0; } const unsigned td_crc = trailer.data_crc(); @@ -134,33 +130,29 @@ int LZ_decoder::check_trailer( const Pretty_print & pp, { error = true; if( verbosity >= 0 ) - { - pp(); - std::fprintf( stderr, "CRC mismatch; stored %08X, computed %08X\n", - td_crc, crc() ); - } + { pp(); + std::fprintf( stderr, "CRC mismatch; stored %08X, computed %08X\n", + td_crc, crc() ); } } + const unsigned long long data_size = data_position(); const unsigned long long td_size = trailer.data_size(); if( td_size != data_size ) { error = true; if( verbosity >= 0 ) - { - pp(); - std::fprintf( stderr, "Data size mismatch; stored %llu (0x%llX), computed %llu (0x%llX)\n", - td_size, td_size, data_size, data_size ); - } + { pp(); + std::fprintf( stderr, "Data size mismatch; stored %llu (0x%llX), computed %llu (0x%llX)\n", + td_size, td_size, data_size, data_size ); } } + const unsigned long long member_size = rdec.member_position(); const unsigned long long tm_size = trailer.member_size(); if( tm_size != member_size ) { error = true; if( verbosity >= 0 ) - { - pp(); - std::fprintf( stderr, "Member size mismatch; stored %llu (0x%llX), computed %llu (0x%llX)\n", - tm_size, tm_size, member_size, member_size ); - } + { pp(); + std::fprintf( stderr, "Member size mismatch; stored %llu (0x%llX), computed %llu (0x%llX)\n", + tm_size, tm_size, member_size, member_size ); } } if( error ) return 3; if( !ignore_empty && data_size == 0 ) return 5; @@ -190,8 +182,8 @@ int LZ_decoder::check_trailer( const Pretty_print & pp, /* Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF, 3 = trailer error, 4 = unknown marker found, 5 = empty member found, 6 = marked member found. */ -int LZ_decoder::decode_member( const Pretty_print & pp, - const bool ignore_empty, const bool ignore_marking ) +int LZ_decoder::decode_member( const Cl_options & cl_opts, + const Pretty_print & pp ) { Bit_model bm_literal[1<= 0 ) -- cgit v1.2.3