diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2016-06-01 14:15:38 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2016-06-01 14:15:38 +0000 |
commit | b74ecd2cc2094c9644123e48ac3e2400fd8a3674 (patch) | |
tree | 8dbdba84d3f38fb2ea33a5f18fea7d42d16e3f8d /file_index.cc | |
parent | Adding upstream version 1.4. (diff) | |
download | plzip-b74ecd2cc2094c9644123e48ac3e2400fd8a3674.tar.xz plzip-b74ecd2cc2094c9644123e48ac3e2400fd8a3674.zip |
Adding upstream version 1.5.upstream/1.5
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | file_index.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/file_index.cc b/file_index.cc index 7e265a1..0e48833 100644 --- a/file_index.cc +++ b/file_index.cc @@ -1,5 +1,5 @@ /* Plzip - Parallel compressor compatible with lzip - Copyright (C) 2009-2015 Antonio Diaz Diaz. + Copyright (C) 2009-2016 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 @@ -50,11 +50,11 @@ void File_index::set_num_error( const char * const msg1, unsigned long long num, char buf[80]; snprintf( buf, sizeof buf, "%s%llu%s", msg1, num, msg2 ); error_ = buf; - retval_ = member_vector.empty() ? 1 : 2; // maybe trailing garbage + retval_ = member_vector.empty() ? 1 : 2; // maybe trailing data } -File_index::File_index( const int infd ) +File_index::File_index( const int infd, const bool ignore_garbage ) : retval_( 0 ) { const long long isize = lseek( infd, 0, SEEK_END ); @@ -88,7 +88,10 @@ File_index::File_index( const int infd ) if( member_size < min_member_size || member_size > pos ) { if( member_vector.empty() && isize - pos < max_garbage ) - { --pos; continue; } // maybe trailing garbage + { + if( ignore_garbage ) { --pos; continue; } // maybe trailing data + error_ = "Trailing data not allowed."; retval_ = 2; return; + } set_num_error( "Member size in trailer is corrupt at pos ", pos - 8 ); break; } @@ -98,7 +101,10 @@ File_index::File_index( const int infd ) if( !header.verify_magic() || !header.verify_version() ) { if( member_vector.empty() && isize - pos < max_garbage ) - { --pos; continue; } // maybe trailing garbage + { + if( ignore_garbage ) { --pos; continue; } // maybe trailing data + error_ = "Trailing data not allowed."; retval_ = 2; return; + } set_num_error( "Bad header at pos ", pos - member_size ); break; } |