[sys_bind] [signalfd] update (#8507)

This commit is contained in:
rcitachi 2024-01-26 22:14:02 +08:00 committed by GitHub
parent 0e409a6eb1
commit 0c96b26c23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View File

@ -6,9 +6,8 @@ cwd = GetCurrentDir()
src = []
CPPPATH = [cwd]
if GetDepend('RT_USING_DFS'):
if GetDepend('RT_USING_MUSLLIBC'):
src += ['signalfd.c']
if GetDepend('RT_USING_POSIX_SIGNALFD'):
src += ['signalfd.c']
group = DefineGroup('POSIX', src, depend = ['RT_USING_SMART','RT_USING_POSIX_SIGNALFD'], CPPPATH = CPPPATH)

View File

@ -3292,6 +3292,7 @@ sysret_t sys_bind(int socket, const struct musl_sockaddr *name, socklen_t namele
{
rt_err_t ret = 0;
struct sockaddr sa;
struct sockaddr_un un_addr;
struct musl_sockaddr kname;
rt_uint16_t family = 0;
@ -3301,14 +3302,24 @@ sysret_t sys_bind(int socket, const struct musl_sockaddr *name, socklen_t namele
}
lwp_get_from_user(&family, (void *)name, 2);
if ((family == AF_UNIX) || (family == AF_NETLINK))
if (family == AF_UNIX)
{
if (!lwp_user_accessable((void *)name, sizeof(struct sockaddr)))
if (!lwp_user_accessable((void *)name, sizeof(struct sockaddr_un)))
{
return -EFAULT;
}
lwp_get_from_user(&sa, (void *)name, sizeof(struct sockaddr));
lwp_get_from_user(&un_addr, (void *)name, sizeof(struct sockaddr_un));
ret = bind(socket, (struct sockaddr *)&un_addr, namelen);
}
else if (family == AF_NETLINK)
{
if (!lwp_user_accessable((void *)name, namelen))
{
return -EFAULT;
}
lwp_get_from_user(&sa, (void *)name, namelen);
ret = bind(socket, &sa, namelen);
}