mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
Heapmath mp_add_d: fix for when a and c same pointer
When parameters a and c to mp_add_d are the same pointer, c->sign was being set to zero/positive and then a->sign was being checked. Set the c->sign at end as it will always be zero/positive through the code and the sign of the result isn't otherwise used.
This commit is contained in:
@@ -4425,9 +4425,6 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) /* //NOLINT(misc-no-recursion) *
|
|||||||
/* old number of used digits in c */
|
/* old number of used digits in c */
|
||||||
oldused = c->used;
|
oldused = c->used;
|
||||||
|
|
||||||
/* sign always positive */
|
|
||||||
c->sign = MP_ZPOS;
|
|
||||||
|
|
||||||
/* source alias */
|
/* source alias */
|
||||||
tmpa = a->dp;
|
tmpa = a->dp;
|
||||||
|
|
||||||
@@ -4478,6 +4475,9 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) /* //NOLINT(misc-no-recursion) *
|
|||||||
ix = 1;
|
ix = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sign always positive */
|
||||||
|
c->sign = MP_ZPOS;
|
||||||
|
|
||||||
/* now zero to oldused */
|
/* now zero to oldused */
|
||||||
while (ix++ < oldused) {
|
while (ix++ < oldused) {
|
||||||
*tmpc++ = 0;
|
*tmpc++ = 0;
|
||||||
|
Reference in New Issue
Block a user