-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #77, integer overflow when parsing JSON scientific notation number. #80
Conversation
@@ -267,8 +267,16 @@ impl<Iter> Deserializer<Iter> | |||
while !self.eof() { | |||
match self.ch_or_null() { | |||
c @ b'0' ... b'9' => { | |||
exp *= 10; | |||
exp += (c as i32) - (b'0' as i32); | |||
macro_rules! try_or_invalid { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pull this macro out to the top level since I also use it for parse_decimal
?
Thanks! Could you also add a test for this? |
Could you expand your patch to include Lines 238 & 239 please. I guess they can panic on invalid input also. |
@erickt, I'm unsure about how test_de works. Does it convert the given Rust value to JSON, and then match it with the expected token output? If so, how do you let it output the scientific notation for a given number? @tomprogrammer, since |
@ProtectedMode You are right, there can't be a panic in these lines. |
@ProtectedMode: Check out https://github.com/serde-rs/serde/blob/master/serde_tests/tests/test_json.rs#L705, which was the test I added for parsing decimal overflow. You probably could just add ("1e777777777777777777777777777", Error::SyntaxError(ErrorCode::InvalidNumber, 1, 22)), |
@erickt, it seems I was confused and missed that file, now it makes sense. I added your test, I will squash the commits if you want. |
Fix #77, integer overflow when parsing JSON scientific notation number.
👏 |
I think this should fix it, but make sure to review it. 😃