psock_socket: Add type field check

behavior alignment to Linux
Return EINVAL when type field include nonsupport bit

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-10-19 21:53:46 +08:00 committed by Xiang Xiao
parent 2be529121a
commit dc577b66e4
1 changed files with 5 additions and 0 deletions

View File

@ -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;