diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-03-16 06:46:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-03-16 06:46:00 +0000 |
commit | d25dcde027d4b19e3d7728f96138210862ed0aa0 (patch) | |
tree | 30c61903dae6754752ffa50918d78a05b58dce90 /extended.cc | |
parent | Releasing debian version 0.13-1. (diff) | |
download | tarlz-d25dcde027d4b19e3d7728f96138210862ed0aa0.tar.xz tarlz-d25dcde027d4b19e3d7728f96138210862ed0aa0.zip |
Merging upstream version 0.14.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extended.cc')
-rw-r--r-- | extended.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/extended.cc b/extended.cc index 5931be2..39b0f5a 100644 --- a/extended.cc +++ b/extended.cc @@ -201,7 +201,9 @@ bool Extended::parse( const char * const buf, const unsigned long long edsize, if( rest > 5 && std::memcmp( tail, "path=", 5 ) == 0 ) { if( path_.size() && !permissive ) return false; - path_.assign( tail + 5, rest - 5 ); + unsigned long long len = rest - 5; + while( len > 1 && tail[5+len-1] == '/' ) --len; // trailing '/' + path_.assign( tail + 5, len ); // this also truncates path_ at the first embedded null character path_.assign( remove_leading_dotslash( path_.c_str() ) ); } @@ -275,3 +277,19 @@ void Extended::fill_from_ustar( const Tar_header header ) ( typeflag == tf_regular || typeflag == tf_hiperf ) ) file_size( parse_octal( header + size_o, size_l ) ); } + + +/* Returns file size from record or from ustar header, and resets file_size_. + Used for fast parsing of headers in uncompressed archives. */ +unsigned long long Extended::get_file_size_and_reset( const Tar_header header ) + { + const unsigned long long tmp = file_size_; + file_size( 0 ); + const Typeflag typeflag = (Typeflag)header[typeflag_o]; + if( typeflag == tf_regular || typeflag == tf_hiperf ) + { + if( tmp == 0 ) return parse_octal( header + size_o, size_l ); + else return tmp; + } + return 0; + } |