serde-rs / serde

Serialization framework for Rust

Home Page:https://serde.rs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integer overflow when parsing JSON scientific notation number

frewsxcv opened this issue · comments

This is a different issue from #75

Code

#![feature(plugin)]
#![plugin(afl_coverage_plugin)]

extern crate afl_coverage;

extern crate serde;

use std::io::{self, Read, Cursor};

use serde::json::{self, Value};


fn main() {
    let mut input = String::new();
    let result = io::stdin().read_to_string(&mut input);
    if result.is_ok() {
        if let Ok(j) = json::from_str::<json::Value>(&input) {
            let _ = json::to_string(&j);
        }
    }
}

Input

[7E-7777777777]

Crash

root@vultr:~/afl-staging-area2# cargo run < outputs/crashes/id\:000008*
     Running `target/debug/afl-staging-area2`
thread '<main>' panicked at 'arithmetic operation overflowed', /root/serde/serde/src/json/de.rs:270
An unknown error occurred

To learn more, run the command again with --verbose.

This bug was found using https://github.com/kmcallister/afl.rs 👍