Commit ba95ef76e0e1c3a5228c446465766d4547c3e623

Kevin B Kenny 2005-05-10T17:20:39

ensure string is null-terminated

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/bn_mp_read_radix.c b/bn_mp_read_radix.c
index 5decdeb..e02f066 100644
--- a/bn_mp_read_radix.c
+++ b/bn_mp_read_radix.c
@@ -71,7 +71,13 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
     }
     ++str;
   }
-  
+
+  /* if an illegal character was found, fail. */
+  if (*str != '\0') {
+      mp_zero(a);
+      return MP_VAL;
+  }
+
   /* set the sign only if a != 0 */
   if (mp_iszero(a) != MP_YES) {
      a->sign = neg;