Repository: ilai-deutel/kibi (language: rust)

Issue:
Fuzz test failure: panic during config parsing
When running"

```bash
$ cargo fuzz run fuzz_config_load
```

Got error message:

```
thread '<unnamed>' panicked at /home/ilai/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/time.rs:981:23:
cannot convert float seconds to Duration: value is either too big or NaN
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Test input (after minimization with `cargo fuzz tmin fuzz_config_load fuzz/artifacts/fuzz_config_load/crash-...`):

```ini
message_duration=77777777777777777777
```

`Duration::from_secs_f32` needs to be replaced with `Duration::try_from_secs_f32`


Discussion / hints:

Fix patch:
diff --git a/src/config.rs b/src/config.rs
index 2d7fd601..884729c5 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -52,13 +52,12 @@ impl Config {
         for path in paths.iter().filter(|p| p.is_file()).rev() {
             process_ini_file(path, &mut |key, value| {
                 match key {
-                    "tab_stop" => match parse_value(value)? {
-                        0 => return Err("tab_stop must be > 0".into()),
-                        tab_stop => conf.tab_stop = tab_stop,
-                    },
+                    "tab_stop" =>
+                        conf.tab_stop = parse_value(value).map_err(|_| "tab_stop must be > 0")?,
                     "quit_times" => conf.quit_times = parse_value(value)?,
                     "message_duration" =>
-                        conf.message_dur = Duration::from_secs_f32(parse_value(value)?),
+                        conf.message_dur = Duration::try_from_secs_f32(parse_value(value)?)
+                            .map_err(|x| x.to_string())?,
                     "show_line_numbers" => conf.show_line_num = parse_value(value)?,
                     _ => return Err(format!("Invalid key: {key}")),
                 };


Test patch: