Chunk size should not be zero.

This commit is contained in:
Con Kolivas 2021-02-14 11:20:53 +11:00
parent 96c7c62584
commit a80c0b5e20
2 changed files with 2 additions and 2 deletions

View file

@ -1006,7 +1006,7 @@ bool get_fileinfo(rzip_control *control)
if (unlikely(read(fd_in, &chunk_size, chunk_byte) != chunk_byte))
fatal_goto(("Failed to read chunk_size in get_fileinfo\n"), error);
chunk_size = le64toh(chunk_size);
if (unlikely(chunk_size < 0))
if (unlikely(chunk_size <= 0))
fatal_goto(("Invalid chunk size %lld\n", chunk_size), error);
}
}

View file

@ -1117,7 +1117,7 @@ void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
sinfo->size = le64toh(sinfo->size);
print_maxverbose("Chunk size: %lld\n", sinfo->size);
control->st_size += sinfo->size;
if (unlikely(sinfo->chunk_bytes < 1 || sinfo->chunk_bytes > 8 || sinfo->size < 0)) {
if (unlikely(sinfo->chunk_bytes < 1 || sinfo->chunk_bytes > 8 || sinfo->size <= 0)) {
print_err("Invalid chunk data size %d bytes %lld\n", sinfo->size, sinfo->chunk_bytes);
goto failed;
}