Skip to content

Commit

Permalink
use H5_IS_BUFFER_OVERFLOW to check overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aled-ua authored Jan 9, 2025
1 parent 826a425 commit d0ae121
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/H5Faccum.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,10 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr
H5_CHECKED_ASSIGN(overlap_size, size_t, (addr + size) - accum->loc, haddr_t);
new_accum_size = accum->size - overlap_size;

/* Ensure overlap_size and new_accum_size are within bounds */
if (overlap_size > accum->alloc_size || new_accum_size > accum->alloc_size) {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"calculated sizes exceed allocated buffer size");
/* Ensure that the memmove operation won't overflow past the buffer's allocated size */
if (H5_IS_BUFFER_OVERFLOW(accum->buf + overlap_size, new_accum_size, accum->buf + accum->alloc_size)) {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"memmove operation would overflow buffer");
}

/* Move the accumulator buffer information to eliminate the freed block */
Expand Down

0 comments on commit d0ae121

Please sign in to comment.