return error if output-buffer is too small

This commit is contained in:
Steffen Jaeckel 2019-09-02 18:17:23 +02:00
parent 6cd570d08b
commit 6927326a6a

View File

@ -48,6 +48,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, int radix)
while (!MP_IS_ZERO(&t)) {
if (--maxlen < 1) {
/* no more room */
err = MP_VAL;
break;
}
if ((err = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
@ -67,7 +68,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, int radix)
*str = '\0';
mp_clear(&t);
return MP_OKAY;
return err;
}
#endif