diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-27 16:11:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-27 16:11:22 +0000 |
commit | 4e8b4f669846da5166cc09ccaeff06710aaeb1b7 (patch) | |
tree | 4d43dd4ea1e336065ba7208e974f29afe542b7d2 /in_place.c | |
parent | Adding upstream version 0.6. (diff) | |
download | xlunzip-4e8b4f669846da5166cc09ccaeff06710aaeb1b7.tar.xz xlunzip-4e8b4f669846da5166cc09ccaeff06710aaeb1b7.zip |
Adding upstream version 0.7.upstream/0.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | in_place.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -1,5 +1,5 @@ /* Xlunzip - Test tool for the lzip_decompress linux module - Copyright (C) 2016-2020 Antonio Diaz Diaz. + Copyright (C) 2016-2021 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 @@ -84,14 +84,15 @@ static uint8_t * read_file( const int infd, long * const buffer_sizep, struct File_sizes { - unsigned long long csize; - unsigned long long dsize; + unsigned long long csize; /* compressed size */ + unsigned long long dsize; /* decompressed size */ + unsigned long tsize; /* trailing data size */ long members; - long trailing; }; static const char * set_file_sizes( struct File_sizes * const file_sizes, - const uint8_t * const buffer, const long file_size ) + const uint8_t * const buffer, + const unsigned long file_size ) { if( file_size <= Lh_size ) return "File ends unexpectedly at member header."; if( file_size < min_member_size ) return "Input file is too short."; @@ -101,8 +102,8 @@ static const char * set_file_sizes( struct File_sizes * const file_sizes, if( !Lh_verify_version( *header ) ) return "Version of lzip member format not supported."; - file_sizes->csize = file_sizes->dsize = 0; - file_sizes->members = file_sizes->trailing = 0; + file_sizes->csize = file_sizes->dsize = file_sizes->tsize = 0; + file_sizes->members = 0; unsigned long pos = file_size; /* always points to a header or to EOF */ while( pos >= min_member_size ) { @@ -128,7 +129,7 @@ static const char * set_file_sizes( struct File_sizes * const file_sizes, } if( file_sizes->csize == 0 && file_size - pos > 0 ) { - file_sizes->trailing = file_size - pos; + file_sizes->tsize = file_size - pos; header = (const Lzip_header *)( buffer + pos ); if( file_size - pos > Lh_size && Lh_verify_magic( *header ) && Lh_verify_version( *header ) ) @@ -140,7 +141,7 @@ static const char * set_file_sizes( struct File_sizes * const file_sizes, ++file_sizes->members; } if( pos != 0 || file_sizes->csize == 0 ) return "Can't get file sizes."; - if( file_sizes->csize + file_sizes->trailing != (unsigned long)file_size ) + if( file_sizes->csize + file_sizes->tsize != file_size ) return "Error getting file sizes."; if( file_sizes->csize > LONG_MAX ) return "File is larger than LONG_MAX."; if( file_sizes->dsize > LONG_MAX ) return "Data is larger than LONG_MAX."; @@ -192,8 +193,6 @@ int decompress_in_place( const int infd, struct Pretty_print * const pp, buffer_size = target_buffer_size; const long cbegin = buffer_size - csize; /* overwrite trailing data */ if( cbegin > 0 ) memmove( buffer + cbegin, buffer, csize ); -/*fprintf( stderr, "buffer_size = %ld, cbegin = %ld, extra_bytes = %ld\n", - buffer_size, cbegin, extra_bytes );*/ long in_pos, out_pos; int retval; |