summaryrefslogtreecommitdiffstats
path: root/file_index.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-06-01 14:15:42 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-06-01 14:15:56 +0000
commit4eb895adce37d5080310984546faf00db136d4ef (patch)
treeaa5e387425ea1b8f34ada52747cbca077a5047e7 /file_index.cc
parentReleasing debian version 1.4-2. (diff)
downloadplzip-4eb895adce37d5080310984546faf00db136d4ef.tar.xz
plzip-4eb895adce37d5080310984546faf00db136d4ef.zip
Merging upstream version 1.5.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--file_index.cc16
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;
}