diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:31:21 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:31:21 +0000 |
commit | 418b05fcd64815e6928cb9751285fa2d29a34361 (patch) | |
tree | 9c3aea706f65d3822c5fb4a526fd8570a7ded89d /decoder.cc | |
parent | Adding upstream version 1.13~rc1. (diff) | |
download | lzip-0b94aa06d0fc9f2af83041c033485c19738562a7.tar.xz lzip-0b94aa06d0fc9f2af83041c033485c19738562a7.zip |
Adding upstream version 1.13~rc2.upstream/1.13_rc2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.cc')
-rw-r--r-- | decoder.cc | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -1,5 +1,5 @@ /* Lzip - Data compressor based on the LZMA algorithm - Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + Copyright (C) 2008, 2009, 2010, 2011, 2012 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 @@ -82,7 +82,7 @@ int writeblock( const int fd, const uint8_t * const buf, const int size ) throw( errno = 0; const int n = write( fd, buf + size - rest, rest ); if( n > 0 ) rest -= n; - else if( errno && errno != EINTR && errno != EAGAIN ) break; + else if( n < 0 && errno != EINTR && errno != EAGAIN ) break; } return ( rest > 0 ) ? size - rest : size; } @@ -124,21 +124,17 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) const const long long member_size = range_decoder.member_position() + trailer_size; bool error = false; - for( int i = 0; i < trailer_size && !error; ++i ) + const int size = range_decoder.read( trailer.data, trailer_size ); + if( size < trailer_size ) { - if( !range_decoder.finished() ) - trailer.data[i] = range_decoder.get_byte(); - else + error = true; + if( pp.verbosity() >= 0 ) { - error = true; - if( pp.verbosity() >= 0 ) - { - pp(); - std::fprintf( stderr, "Trailer truncated at trailer position %d;" - " some checks may fail.\n", i ); - } - for( ; i < trailer_size; ++i ) trailer.data[i] = 0; + pp(); + std::fprintf( stderr, "Trailer truncated at trailer position %d;" + " some checks may fail.\n", size ); } + for( int i = size; i < trailer_size; ++i ) trailer.data[i] = 0; } if( member_version == 0 ) trailer.member_size( member_size ); if( !range_decoder.code_is_zero() ) @@ -292,7 +288,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) if( pp.verbosity() >= 0 ) { pp(); - std::fprintf( stderr, "Unsupported marker code `%d'.\n", len ); + std::fprintf( stderr, "Unsupported marker code '%d'.\n", len ); } return 4; } |