1
0
Fork 0

Merging upstream version 1.13~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 06:03:46 +01:00
parent f40403d840
commit 95e3ee3bd3
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
29 changed files with 472 additions and 517 deletions

View file

@ -244,7 +244,7 @@ bool set_data_feeder( const std::string & filename, int * const infdp,
}
// Return format_index, or -1 if uncompressed.
// Return format_index, or -1 if uncompressed or shorter than magic_buf_size.
//
int test_format( const int infd, uint8_t magic_data[],
int * const magic_sizep )
@ -269,22 +269,24 @@ int test_format( const int infd, uint8_t magic_data[],
{ 0x28, 0xB5, 0x2F, 0xFD }; // 0xFD2FB528 LE
*magic_sizep = readblock( infd, magic_data, magic_buf_size );
if( *magic_sizep == magic_buf_size ) // test formats in search order
{
if( std::memcmp( magic_data, lzip_magic, lzip_magic_size ) == 0 &&
isvalid_ds( magic_data[lzip_magic_size] ) )
return fmt_lz;
if( std::memcmp( magic_data, bzip2_magic, bzip2_magic_size ) == 0 &&
magic_data[3] >= '1' && magic_data[3] <= '9' &&
std::memcmp( magic_data + 4, "1AY&SY", 6 ) == 0 )
return fmt_bz2;
if( std::memcmp( magic_data, gzip_magic, gzip_magic_size ) == 0 ||
std::memcmp( magic_data, compress_magic, compress_magic_size ) == 0 )
return fmt_gz;
if( std::memcmp( magic_data, zstd_magic, zstd_magic_size ) == 0 )
return fmt_zst;
if( std::memcmp( magic_data, xz_magic, xz_magic_size ) == 0 )
return fmt_xz;
}
if( *magic_sizep < magic_buf_size )
{ if( errno ) return -1; // read error
for( int i = *magic_sizep; i < magic_buf_size; ++i ) magic_data[i] = 0; }
// test formats in search order
if( std::memcmp( magic_data, lzip_magic, lzip_magic_size ) == 0 &&
isvalid_ds( magic_data[lzip_magic_size] ) )
return fmt_lz;
if( std::memcmp( magic_data, bzip2_magic, bzip2_magic_size ) == 0 &&
magic_data[3] >= '1' && magic_data[3] <= '9' &&
( std::memcmp( magic_data + 4, "1AY&SY", 6 ) == 0 ||
std::memcmp( magic_data + 4, "\x17rE8P\x90", 6 ) == 0 ) )
return fmt_bz2;
if( std::memcmp( magic_data, gzip_magic, gzip_magic_size ) == 0 ||
std::memcmp( magic_data, compress_magic, compress_magic_size ) == 0 )
return fmt_gz;
if( std::memcmp( magic_data, zstd_magic, zstd_magic_size ) == 0 )
return fmt_zst;
if( std::memcmp( magic_data, xz_magic, xz_magic_size ) == 0 )
return fmt_xz;
return -1;
}