From 9e7065c85af89b207b8b63d40641a3b3fdcbc96c Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Tue, 27 Oct 2026 19:21:16 +0800 Subject: [PATCH] [net][sal] validate RAW socket protocol (#11888) * [net][sal] validate RAW socket protocol - replace the IPPROTO_RAW-only check with VALID_PROTOCOL() - allow RAW sockets for protocols such as ICMP - keep the existing domain and type validation unchanged * [net][sal] fix clang-format alignment - align the macro continuation after the RAW protocol check - no functional change --- components/net/sal/src/sal_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/net/sal/src/sal_socket.c b/components/net/sal/src/sal_socket.c index 509da973e2..2367e1441c 100644 --- a/components/net/sal/src/sal_socket.c +++ b/components/net/sal/src/sal_socket.c @@ -49,7 +49,7 @@ (((domain) == AF_INET || (domain) == AF_INET6) && \ (((type) == SOCK_STREAM && ((protocol) == 0 || (protocol) == IPPROTO_TCP)) || \ ((type) == SOCK_DGRAM && ((protocol) == 0 || (protocol) == IPPROTO_UDP)) || \ - ((type) == SOCK_RAW && ((protocol) == IPPROTO_RAW)))) || \ + ((type) == SOCK_RAW && VALID_PROTOCOL(protocol)))) || \ ((domain) == AF_UNIX && ((type) == SOCK_STREAM || (type) == SOCK_DGRAM) && (protocol) == 0) || \ ((domain) == AF_NETLINK && (type) == SOCK_RAW && (protocol) == 0))