Skip to content

Commit

Permalink
Merge branch 'fix-config'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 26, 2023
2 parents 7e2add3 + 329561a commit 7ddf948
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gix-config-value/src/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ impl TryFrom<&BStr> for Integer {
return Err(int_err(s));
}

let last_idx = s.len() - 1;
if !s.is_char_boundary(last_idx) {
return Err(int_err(s));
}

let (number, suffix) = s.split_at(s.len() - 1);
if let (Ok(value), Ok(suffix)) = (number.parse(), suffix.parse()) {
Ok(Self {
Expand Down
1 change: 1 addition & 0 deletions gix-config-value/tests/value/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn invalid_from_str() {
assert!(Integer::try_from(b("g")).is_err());
assert!(Integer::try_from(b("123123123123123123123123")).is_err());
assert!(Integer::try_from(b("gg")).is_err());
assert!(Integer::try_from(b("™️🤦‍♂️")).is_err());
}

#[test]
Expand Down
2 changes: 0 additions & 2 deletions gix-config/fuzz/fuzz_targets/fuzz_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use gix_config::{
File,
};
use libfuzzer_sys::fuzz_target;
use std::error::Error;
use std::fmt;
use std::hint::black_box;

#[derive(Arbitrary, Debug)]
Expand Down

0 comments on commit 7ddf948

Please sign in to comment.