Skip to content

Commit be90fe0

Browse files
committed
tfm and integer: skip whitespace at end in radix read
1 parent 7ebb8cd commit be90fe0

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

wolfcrypt/src/integer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,6 +5358,9 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
53585358
++str;
53595359
}
53605360

5361+
/* Skip whitespace at end of str */
5362+
while (CharIsWhiteSpace(*str))
5363+
++str;
53615364
/* if digit in isn't null term, then invalid character was found */
53625365
if (*str != '\0') {
53635366
mp_zero (a);

wolfcrypt/src/tfm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6029,7 +6029,13 @@ static int fp_read_radix(fp_int *a, const char *str, int radix)
60296029
}
60306030
}
60316031
if (y >= radix) {
6032-
return FP_VAL;
6032+
/* Check if whitespace at end of line */
6033+
while (CharIsWhiteSpace(*str))
6034+
++str;
6035+
if (*str)
6036+
return FP_VAL;
6037+
else
6038+
break;
60336039
}
60346040

60356041
/* if the char was found in the map

0 commit comments

Comments
 (0)