Skip to content

Commit b2a467c

Browse files
3393304070trufae
authored andcommitted
Fixed out-of-bound write in libbf.c
1 parent 7b41be3 commit b2a467c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

shlr/qjs/src/libbf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,11 @@ static int __bf_div(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec,
16941694
slimb_t d;
16951695

16961696
na = n + nb;
1697+
1698+
if (na >= (SIZE_MAX / sizeof(limb_t)) - 1) {
1699+
return BF_ST_MEM_ERROR; /* Return memory error status */
1700+
}
1701+
16971702
taba = bf_malloc(s, (na + 1) * sizeof(limb_t));
16981703
if (!taba)
16991704
goto fail;

0 commit comments

Comments
 (0)