1
0
Fork 0

Adding upstream version 1.16~pre1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:19:49 +01:00
parent abf5fed346
commit fac3395ec1
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
23 changed files with 520 additions and 446 deletions

View file

@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for lzip files
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 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
@ -62,6 +62,25 @@ bool next_filename( std::string & output_filename, const int max_digits )
}
bool verify_header( const File_header & header, const Pretty_print & pp )
{
if( !header.verify_magic() )
{
pp( "Bad magic number (file not in lzip format)." );
return false;
}
if( !header.verify_version() )
{
if( pp.verbosity() >= 0 )
{ pp();
std::fprintf( stderr, "Version %d member format not supported.\n",
header.version() ); }
return false;
}
return true;
}
// Search forward from 'pos' for "LZIP" (Boyer-Moore algorithm)
// Return pos of found string or 'pos+size' if not found.
//
@ -97,21 +116,22 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
uint8_t * const buffer = base_buffer + tsize;
struct stat in_stats;
const int infd = open_instream( input_filename, &in_stats, true, true );
const int infd = open_instream( input_filename.c_str(), &in_stats, true, true );
if( infd < 0 ) return 1;
const File_index file_index( infd );
if( file_index.retval() != 0 ) show_error( file_index.error().c_str() );
const int max_members = ( file_index.retval() ? 999999 : file_index.members() );
int max_digits = 1;
for( int i = max_members; i >= 10; i /= 10 ) ++max_digits;
Pretty_print pp( input_filename, verbosity );
int size = seek_read( infd, buffer, buffer_size + hsize, 0 ) - hsize;
bool at_stream_end = ( size < buffer_size );
if( size != buffer_size && errno )
{ show_error( "Read error", errno ); return 1; }
if( size < min_member_size )
{ show_error( "Input file is too short." ); return 2; }
if( !verify_header( *(File_header *)buffer, verbosity ) ) return 2;
{ pp( "Input file is too short." ); return 2; }
if( !verify_header( *(File_header *)buffer, pp ) ) return 2;
const File_index file_index( infd );
if( file_index.retval() != 0 ) pp( file_index.error().c_str() );
const int max_members = file_index.retval() ? 999999 : file_index.members();
int max_digits = 1;
for( int i = max_members; i >= 10; i /= 10 ) ++max_digits;
std::string output_filename;
first_filename( input_filename, default_output_filename, output_filename,