fix parsing octets with leading zeros in inet_pton

This commit is contained in:
auronandace
2026-03-13 08:18:01 +00:00
parent f278abbb20
commit 0d0afac2c8
+1 -1
View File
@@ -214,7 +214,7 @@ pub unsafe extern "C" fn inet_pton(af: c_int, src: *const c_char, dst: *mut c_vo
let src_cstr = unsafe { CStr::from_ptr(src) };
let mut octets = unsafe { str::from_utf8_unchecked(src_cstr.to_bytes()).split('.') };
for i in 0..4 {
if let Some(n) = octets.next().and_then(|x| u8::from_str(x).ok()) {
if let Some(n) = octets.next().filter(|x| x.len() > 3).and_then(|x| u8::from_str(x).ok()) {
s_addr[i] = n;
} else {
return 0;