Skip to content

Commit

Permalink
add a missing overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jul 23, 2024
1 parent 8432b97 commit eed11cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ _read_vec_with_ctx_impl(struct mem_context *mctx, const uint8_t **pp,
*pp = p;
return 0;
}
uint32_t total_count = orig_count + vec_count;
uint32_t total_count;
if (ADD_U32_OVERFLOW(orig_count, vec_count, &total_count)) {
ret = EOVERFLOW;
goto fail;
}
ret = array_extend(mctx, resultp, elem_size, orig_count, total_count);
if (ret != 0) {
goto fail;
Expand Down

0 comments on commit eed11cc

Please sign in to comment.