@@ -31,8 +31,11 @@ void file_reader::init(int fd, size_t uncompressed_size, size_t uncompressed_tar
3131 const uint8_t version = (uint8_t )compressed_data[0 ];
3232 assert (version == 1 );
3333 compression_algorithm = compressed_data[1 ];
34- assert (compression_algorithm == LAVATUBE_COMPRESSION_DENSITY || compression_algorithm == LAVATUBE_COMPRESSION_LZ4 );
34+ assert (compression_algorithm == LAVATUBE_COMPRESSION_DENSITY || compression_algorithm == LAVATUBE_COMPRESSION_LZ4 || compression_algorithm == LAVATUBE_COMPRESSION_UNCOMPRESSED );
35+ const size_t header_bytes = strlen (magic_word) + 32 ;
36+ assert (total_left >= header_bytes);
3537 compressed_data += 32 ; // the rest is reserved space
38+ total_left -= header_bytes;
3639 (void )version;
3740 (void )compression_algorithm;
3841 }
@@ -109,12 +112,17 @@ void file_reader::decompress_chunk()
109112 density_processing_result result = density_decompress ((const uint8_t *)compressed_data, compressed_size, destination, estimated_size);
110113 if (result.state != DENSITY_STATE_OK ) ABORT (" Failed to decompress infile - aborting" );
111114 }
112- else // LZ4
115+ else if (compression_algorithm == LAVATUBE_COMPRESSION_LZ4 )
113116 {
114117 int result = LZ4_decompress_safe (compressed_data, (char *)destination, compressed_size, uncompressed_size);
115118 if (result < 0 ) ABORT (" Failed to decompress infile - aborting read thread" );
116119 if ((uint64_t )result != uncompressed_size) ABORT (" Failed to decompress the full chunk in infile - aborting read thread" );
117120 }
121+ else // uncompressed
122+ {
123+ assert (compression_algorithm == LAVATUBE_COMPRESSION_UNCOMPRESSED );
124+ memcpy (destination, compressed_data, uncompressed_size);
125+ }
118126 compressed_data += compressed_size;
119127 write_position += uncompressed_size;
120128 total_left -= compressed_size + header_size;
0 commit comments