From 9cdc75a930c626f5976f001849353823e79d48e1 Mon Sep 17 00:00:00 2001 From: Jean Pierre Dudey Date: Wed, 22 Aug 2018 14:00:30 -0400 Subject: [PATCH] Forbid exponents larger than 18. Signed-off-by: Jean Pierre Dudey --- src/util/decimal.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util/decimal.rs b/src/util/decimal.rs index 6762517..ab308eb 100644 --- a/src/util/decimal.rs +++ b/src/util/decimal.rs @@ -156,7 +156,12 @@ impl Decimal { } } } - if past_dec { exponent += 1; } + if past_dec { + exponent += 1; + if exponent > 18 { + return Err(ParseDecimalError::TooBig); + } + } } b'.' => { past_dec = true; } _ => { /* whitespace or something, just ignore it */ } @@ -314,7 +319,12 @@ impl UDecimal { } } } - if past_dec { exponent += 1; } + if past_dec { + exponent += 1; + if exponent > 18 { + return Err(ParseDecimalError::TooBig); + } + } } b'.' => { past_dec = true; } _ => { /* whitespace or something, just ignore it */ }