diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r-- | sysdeps/unix/sysv/linux/recvmsg.c | 58 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sigstack.c | 1 |
2 files changed, 21 insertions, 38 deletions
diff --git a/sysdeps/unix/sysv/linux/recvmsg.c b/sysdeps/unix/sysv/linux/recvmsg.c index 66970bcb89..52a0abcf67 100644 --- a/sysdeps/unix/sysv/linux/recvmsg.c +++ b/sysdeps/unix/sysv/linux/recvmsg.c @@ -39,53 +39,35 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) { struct cmsghdr *cm; int ret; - int found_creds = 0; - /* Must check for space first. */ + ret = __syscall_recvmsg (fd, message, flags); + + if (ret == -1) + return ret; + + /* Postprocess the message control block for SCM_CREDS. */ cm = CMSG_FIRSTHDR (message); while (cm) { if (cm->cmsg_type == SCM_CREDS) - { - if (cm->cmsg_len < CMSG_SPACE (sizeof (struct cmsgcred))) - { - __set_errno (EINVAL); - return -1; - } - found_creds = 1; + { + struct cmsgcred *c = (struct cmsgcred *) CMSG_DATA (cm); + struct __kernel_ucred u; + int i; + memcpy (&u, CMSG_DATA (cm), sizeof (struct __kernel_ucred)); + + c->cmcred_pid = u.pid; + c->cmcred_uid = u.uid; + c->cmcred_gid = u.gid; + + c->cmcred_euid = -1; + c->cmcred_ngroups = 0; + for (i = 0; i < CMGROUP_MAX; i++) + c->cmcred_groups[i] = -1; } cm = CMSG_NXTHDR (message, cm); } - - ret = __syscall_recvmsg (fd, message, flags); - - if (ret == -1) - return ret; - - /* Postprocess the message control block for SCM_CREDS. */ - cm = CMSG_FIRSTHDR (message); - if (found_creds) - while (cm) - { - if (cm->cmsg_type == SCM_CREDS) - { - struct cmsgcred *c = (struct cmsgcred *) CMSG_DATA (cm); - struct __kernel_ucred u; - int i; - memcpy (&u, CMSG_DATA (cm), sizeof (struct __kernel_ucred)); - - c->cmcred_pid = u.pid; - c->cmcred_uid = u.uid; - c->cmcred_gid = u.gid; - - c->cmcred_euid = -1; - c->cmcred_ngroups = 0; - for (i = 0; i < CMGROUP_MAX; i++) - c->cmcred_groups[i] = -1; - } - cm = CMSG_NXTHDR (message, cm); - } return ret; } diff --git a/sysdeps/unix/sysv/linux/sigstack.c b/sysdeps/unix/sysv/linux/sigstack.c index cbae972048..eb95f20785 100644 --- a/sysdeps/unix/sysv/linux/sigstack.c +++ b/sysdeps/unix/sysv/linux/sigstack.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <signal.h> +#include <stddef.h> #include <sys/syscall.h> |