Skip to content

Commit f74c4a9

Browse files
committed
Fix vuln OSV-2024-381
1 parent 966454a commit f74c4a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/H5Faccum.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,12 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr
894894
H5_CHECKED_ASSIGN(overlap_size, size_t, (addr + size) - accum->loc, haddr_t);
895895
new_accum_size = accum->size - overlap_size;
896896

897+
/* Ensure overlap_size does not exceed accum->size */
898+
if (overlap_size > accum->size) {
899+
accum->loc = HADDR_UNDEF;
900+
accum->size = 0;
901+
accum->dirty = FALSE;
902+
} else {
897903
/* Move the accumulator buffer information to eliminate the freed block */
898904
HDmemmove(accum->buf, accum->buf + overlap_size, new_accum_size);
899905

@@ -918,6 +924,7 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr
918924
} /* end else */
919925
} /* end if */
920926
} /* end else */
927+
} /* end else */
921928
} /* end if */
922929
/* Block to free must start within the accumulator */
923930
else {

0 commit comments

Comments
 (0)