restrict octal prefix to leading zero

the '0o' prefix is only allowed by C2Y, not by C17
POSIX spec defers to C17
This commit is contained in:
sourceturner
2026-06-02 18:41:43 +02:00
parent b2da042f79
commit 125d48e9cd
+3 -1
View File
@@ -61,7 +61,9 @@ pub unsafe extern "C" fn inet_aton(cp: *const c_char, inp: *mut in_addr) -> c_in
{
match hex_or_oct.bytes().next() {
Some(b'x' | b'X') => u32::from_str_radix(&hex_or_oct[1..], 16),
Some(b'o' | b'O') => u32::from_str_radix(&hex_or_oct[1..], 8),
// While it is true that C2Y accepts 0o and 0O as octal prefixes, C17 doesn't
// The POSIX spec defers to C17
// see https://pubs.opengroup.org/onlinepubs/9799919799/functions/inet_addr.html
_ => u32::from_str_radix(&hex_or_oct, 8),
}
} else {