aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-04-12 04:46:36 +0000
committerlloyd <[email protected]>2008-04-12 04:46:36 +0000
commitcf86b705be37b125701e94cb4041a18f5d5f29fd (patch)
tree95ce305479e12da1e48f1b8835a83f763738b531
parentfe767bdcee2b44d23786dad911143f16f5a4162a (diff)
In decimal string inputs: ignore spaces, and for other bad inputs throw
an exception saying so.
-rw-r--r--src/big_code.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/big_code.cpp b/src/big_code.cpp
index 4755e3cc1..824cbb63e 100644
--- a/src/big_code.cpp
+++ b/src/big_code.cpp
@@ -124,6 +124,13 @@ BigInt BigInt::decode(const byte buf[], u32bit length, Base base)
const u32bit RADIX = ((base == Decimal) ? 10 : 8);
for(u32bit j = 0; j != length; ++j)
{
+ if(Charset::is_space(buf[j]))
+ continue;
+
+ if(!Charset::is_digit(buf[j]))
+ throw Invalid_Argument("BigInt::decode: "
+ "Invalid character in decimal input");
+
byte x = Charset::char2digit(buf[j]);
if(x >= RADIX)
{