Fixed out-of-bound write in libbf.c

This commit is contained in:
3393304070 2024-09-15 17:59:56 +01:00 committed by GitHub
parent 6e2e68fd08
commit f4d9fcfc5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1715,6 +1715,11 @@ static int __bf_div(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec,
slimb_t d;
na = n + nb;
if (na >= (SIZE_MAX / sizeof(limb_t)) - 1) {
return BF_ST_MEM_ERROR;
}
taba = bf_malloc(s, (na + 1) * sizeof(limb_t));
if (!taba)
goto fail;