TFM div: fix initial value of size in q so clamping doesn't OOB read

This commit is contained in:
Sean Parkinson
2020-11-16 09:29:13 +10:00
parent e9f0cb234b
commit 837de435ba

View File

@@ -679,7 +679,8 @@ int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
#endif
fp_init(q);
q->used = a->used + 2;
/* qb + d = a, and b is an integer > 0, therefore q <= a */
q->used = a->used;
fp_init(t1);
fp_init(t2);