From 125d48e9cd8e0ebe8d68716018655602aac6b2bb Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Tue, 2 Jun 2026 18:41:43 +0200 Subject: [PATCH] restrict octal prefix to leading zero the '0o' prefix is only allowed by C2Y, not by C17 POSIX spec defers to C17 --- src/header/arpa_inet/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/header/arpa_inet/mod.rs b/src/header/arpa_inet/mod.rs index 77d0aefc19..cc46168044 100644 --- a/src/header/arpa_inet/mod.rs +++ b/src/header/arpa_inet/mod.rs @@ -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 {