Skip to content

Commit ff56cbc

Browse files
committed
Fix vuln OSV-2024-381
1 parent f264298 commit ff56cbc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/H5Faccum.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,11 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr
881881
H5_CHECKED_ASSIGN(overlap_size, size_t, (addr + size) - accum->loc, haddr_t);
882882
new_accum_size = accum->size - overlap_size;
883883

884+
/* Ensure overlap_size and new_accum_size are within bounds */
885+
if (overlap_size > accum->alloc_size || new_accum_size > accum->alloc_size) {
886+
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "calculated sizes exceed allocated buffer size");
887+
}
888+
884889
/* Move the accumulator buffer information to eliminate the freed block */
885890
memmove(accum->buf, accum->buf + overlap_size, new_accum_size);
886891

0 commit comments

Comments
 (0)