Skip to content

Commit 34db770

Browse files
committed
Fix for recent fuzzer issue
1 parent ac116b4 commit 34db770

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

blosc/blosc2.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,18 @@ int read_chunk_header(const uint8_t* src, int32_t srcsize, bool extended_header,
728728
if (special_type == BLOSC2_SPECIAL_VALUE) {
729729
// In this case, the actual type size must be derived from the cbytes
730730
int32_t typesize = header->cbytes - BLOSC_EXTENDED_HEADER_LENGTH;
731+
if (typesize <= 0) {
732+
BLOSC_TRACE_ERROR("`typesize` is zero or negative");
733+
return BLOSC2_ERROR_INVALID_HEADER;
734+
}
735+
if (typesize > BLOSC2_MAXTYPESIZE) {
736+
BLOSC_TRACE_ERROR("`typesize` is greater than maximum allowed");
737+
return BLOSC2_ERROR_INVALID_HEADER;
738+
}
739+
if (typesize > header->nbytes) {
740+
BLOSC_TRACE_ERROR("`typesize` is greater than `nbytes`");
741+
return BLOSC2_ERROR_INVALID_HEADER;
742+
}
731743
if (header->nbytes % typesize != 0) {
732744
BLOSC_TRACE_ERROR("`nbytes` is not a multiple of typesize");
733745
return BLOSC2_ERROR_INVALID_HEADER;

0 commit comments

Comments
 (0)