From dc577b66e45b569293c3c7b080abe6a3987831d8 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Wed, 19 Oct 2022 21:53:46 +0800 Subject: [PATCH] psock_socket: Add type field check behavior alignment to Linux Return EINVAL when type field include nonsupport bit Signed-off-by: zhanghongyu --- net/socket/socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/socket/socket.c b/net/socket/socket.c index 61eab6a638..12e6649b2e 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -82,6 +82,11 @@ int psock_socket(int domain, int type, int protocol, FAR const struct sock_intf_s *sockif = NULL; int ret; + if (type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK | SOCK_TYPE_MASK)) + { + return -EINVAL; + } + /* Initialize the socket structure */ psock->s_domain = domain;