Fix v1 archive decompression
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 5s

Previous implementation sent too many bytes to decompressor if size was
less than 1024.
This commit is contained in:
Stephen Seo 2024-09-30 15:45:48 +09:00
parent 64cfe57724
commit dd29550649

View file

@ -2570,8 +2570,10 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract,
fprintf(stderr, "ERROR Failed to read chunk for decompressing!\n"); fprintf(stderr, "ERROR Failed to read chunk for decompressing!\n");
return SDAS_INTERNAL_ERROR; return SDAS_INTERNAL_ERROR;
} }
ssize_t write_ret = write(pipe_into_cmd[1], buf, 1024); ssize_t write_ret =
if (write_ret > 0 && (size_t)write_ret == 1024) { write(pipe_into_cmd[1], buf, chunk_size - chunk_written);
if (write_ret > 0 &&
(size_t)write_ret == chunk_size - chunk_written) {
// Successful write. // Successful write.
} else if (write_ret == -1) { } else if (write_ret == -1) {
fprintf(stderr, fprintf(stderr,