diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-03-16 06:45:57 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-03-16 06:45:57 +0000 |
commit | 85afea931c3a021e186e81f55b9d969f14d14e41 (patch) | |
tree | 66639fa7ecd0ae38763a9097ceed2a577548623a /list_lz.cc | |
parent | Adding upstream version 0.13. (diff) | |
download | tarlz-85afea931c3a021e186e81f55b9d969f14d14e41.tar.xz tarlz-85afea931c3a021e186e81f55b9d969f14d14e41.zip |
Adding upstream version 0.14.upstream/0.14
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'list_lz.cc')
-rw-r--r-- | list_lz.cc | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -149,6 +149,7 @@ bool check_skip_filename( const Arg_parser & parser, std::vector< char > & name_pending, const char * const filename, const int filenames ) { + if( Exclude::excluded( filename ) ) return true; // skip excluded bool skip = filenames > 0; if( skip ) for( int i = 0; i < parser.arguments(); ++i ) @@ -377,7 +378,8 @@ int list_member_lz( LZ_Decoder * const decoder, const int infd, } if( verbosity < 0 || skip ) rbuf()[0] = 0; - else format_member_name( extended, header, rbuf, verbosity > 0 ); + else if( !format_member_name( extended, header, rbuf, verbosity > 0 ) ) + { *msg = mem_msg; return 1; } const Packet * const opacket = new Packet( member_id, rbuf(), data_rest ? Packet::ok : Packet::member_done ); if( !courier.collect_packet( opacket, worker_id ) ) @@ -404,19 +406,19 @@ int parse_records_lz( LZ_Decoder * const decoder, const int infd, long long & file_pos, const long long member_end, const long long cdata_size, long long & data_pos, Extended & extended, const Tar_header header, - const char ** msg, const bool permissive ) + Resizable_buffer & rbuf, const char ** msg, + const bool permissive ) { const unsigned long long edsize = parse_octal( header + size_o, size_l ); const unsigned long long bufsize = round_up( edsize ); - if( bufsize == 0 || edsize == 0 || edsize >= 1ULL << 33 ) - return false; // overflow or no extended data - char * const buf = new char[bufsize]; // extended records buffer + if( edsize == 0 || edsize >= 1ULL << 33 || bufsize == 0 || bufsize >= INT_MAX ) + return 1; // overflow or no extended data + if( !rbuf.resize( bufsize ) ) return 1; // extended records buffer int retval = archive_read_lz( decoder, infd, file_pos, member_end, - cdata_size, (uint8_t *)buf, bufsize, msg ); + cdata_size, (uint8_t *)rbuf(), bufsize, msg ); if( retval == 0 ) - { if( extended.parse( buf, edsize, permissive ) ) data_pos += bufsize; + { if( extended.parse( rbuf(), edsize, permissive ) ) data_pos += bufsize; else retval = 1; } - delete[] buf; return retval; } @@ -452,7 +454,7 @@ extern "C" void * tworker( void * arg ) const int missing_crc = tmp.missing_crc; const bool permissive = tmp.permissive; - Resizable_buffer rbuf( initial_line_length ); + Resizable_buffer rbuf; LZ_Decoder * const decoder = LZ_decompress_open(); if( !rbuf.size() || !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) { show_error( mem_msg ); cleanup_and_fail(); } @@ -518,7 +520,8 @@ extern "C" void * tworker( void * arg ) cleanup_and_fail( 2 ); } Extended dummy; // global headers are parsed and ignored const int ret = parse_records_lz( decoder, infd, file_pos, member_end, - cdata_size, data_pos, dummy, header, &msg, true ); + cdata_size, data_pos, dummy, header, + rbuf, &msg, true ); if( ret != 0 ) { if( !courier.request_mastership( i, worker_id ) ) goto done; @@ -542,7 +545,8 @@ extern "C" void * tworker( void * arg ) { msg = "Format violation: consecutive extended headers found."; ret = 2; } else ret = parse_records_lz( decoder, infd, file_pos, member_end, - cdata_size, data_pos, extended, header, &msg, permissive ); + cdata_size, data_pos, extended, header, + rbuf, &msg, permissive ); if( ret == 0 && !extended.crc_present() && missing_crc ) { msg = "Missing CRC in extended records."; ret = 2; } if( ret != 0 ) @@ -588,7 +592,7 @@ done: if( LZ_decompress_close( decoder ) < 0 ) { const Packet * const opacket = new Packet( lzip_index.members(), - "LZ_decompress_close failed.", Packet::error ); + "LZ_decompress_close failed.", Packet::error ); courier.collect_packet( opacket, worker_id ); } courier.worker_finished(); |