1
0
Fork 0

Adding upstream version 1.14~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 10:16:51 +01:00
parent f9853ec595
commit 235b8157b9
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
23 changed files with 824 additions and 667 deletions

View file

@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for lzipped files
Copyright (C) 2009, 2010, 2011, 2012 Antonio Diaz Diaz.
Copyright (C) 2009, 2010, 2011, 2012, 2013 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
@ -83,7 +83,8 @@ int find_magic( const uint8_t * const buffer, const int pos, const int size )
int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
const std::string & default_output_filename, const bool force )
const std::string & default_output_filename,
const int verbosity, const bool force )
{
const int hsize = File_header::size;
const int tsize = File_trailer::size();
@ -99,16 +100,16 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
bool at_stream_end = ( size < buffer_size );
if( size != buffer_size && errno )
{ show_error( "Read error", errno ); return 1; }
if( size <= tsize )
if( size < min_member_size )
{ show_error( "Input file is too short." ); return 2; }
if( !verify_header( *(File_header *)buffer ) ) return 2;
if( !verify_header( *(File_header *)buffer, verbosity ) ) return 2;
std::string output_filename;
first_filename( input_filename, default_output_filename, output_filename );
int outfd = open_outstream_rw( output_filename, force );
if( outfd < 0 ) { close( infd ); return 1; }
long long partial_member_size = 0;
unsigned long long partial_member_size = 0;
while( true )
{
int pos = 0;
@ -117,10 +118,8 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
newpos = find_magic( buffer, newpos, size + 4 - newpos );
if( newpos <= size )
{
long long member_size = 0;
for( int i = 1; i <= 8; ++i )
{ member_size <<= 8; member_size += base_buffer[tsize+newpos-i]; }
if( partial_member_size + newpos - pos == member_size )
const File_trailer & trailer = *(File_trailer *)(base_buffer + newpos);
if( partial_member_size + newpos - pos == trailer.member_size() )
{ // header found
const int wr = writeblock( outfd, buffer + pos, newpos - pos );
if( wr != newpos - pos )
@ -167,11 +166,12 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
int split_file( const std::string & input_filename,
const std::string & default_output_filename, const bool force )
const std::string & default_output_filename,
const int verbosity, const bool force )
{
uint8_t * base_buffer;
const int retval = do_split_file( input_filename, base_buffer,
default_output_filename, force );
default_output_filename, verbosity, force );
delete[] base_buffer;
return retval;
}