1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

linux: Check for null value msghdr struct before use

This avoids crashes in libc when cmsg is null and refrencing msg
structure when it is null

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Khem Raj
2021-07-02 13:28:10 -07:00
committed by Adhemerval Zanella
parent 91fb0f17a5
commit c8935581de
2 changed files with 4 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ __libc_recvmsg (int fd, struct msghdr *msg, int flags)
{
ssize_t r;
#ifndef __ASSUME_TIME64_SYSCALLS
socklen_t orig_controllen = msg->msg_controllen;
socklen_t orig_controllen = msg != NULL ? msg->msg_controllen : 0;
#endif
#ifdef __ASSUME_RECVMSG_SYSCALL
@@ -35,7 +35,7 @@ __libc_recvmsg (int fd, struct msghdr *msg, int flags)
#endif
#ifndef __ASSUME_TIME64_SYSCALLS
if (r >= 0)
if (r >= 0 && orig_controllen != 0)
__convert_scm_timestamps (msg, orig_controllen);
#endif