mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "zhuyan (M)" <zhuyan34@huawei.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Cc: Zengweilin <zengweilin@huawei.com>,
	"liucheng (G)" <liucheng32@huawei.com>,
	"chenzefeng (A)" <chenzefeng2@huawei.com>
Subject: [musl] [PATCH] fix segfault in recvmsg when msg argument is NULL
Date: Tue, 26 Jan 2021 02:32:19 +0000	[thread overview]
Message-ID: <19ad44ec8af24e8e8b70860f46438b19@huawei.com> (raw)
In-Reply-To: <20210112075724.58561-1-zhuyan34@huawei.com>


When msg is NULL, msg->msg_controllen exists to dereference a null pointer in recvmsg.

The commit ae388becb529428ac926da102f1d025b3c3968da introduces this problem

Signed-off-by: Qing Wu <wuqing30@huawei.com>
Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
---
 src/network/recvmsg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/network/recvmsg.c b/src/network/recvmsg.c index 03641625..c36ffb8d 100644
--- a/src/network/recvmsg.c
+++ b/src/network/recvmsg.c
@@ -4,6 +4,7 @@
 #include <sys/time.h>
 #include <string.h>
 #include "syscall.h"
+#include <errno.h>
 
 hidden void __convert_scm_timestamps(struct msghdr *, socklen_t);
 
@@ -49,6 +50,8 @@ void __convert_scm_timestamps(struct msghdr *msg, socklen_t csize)
 
 ssize_t recvmsg(int fd, struct msghdr *msg, int flags)  {
+	if (!msg) return -EINVAL;
+
 	ssize_t r;
 	socklen_t orig_controllen = msg->msg_controllen;  #if LONG_MAX > INT_MAX
--
2.12.3


      parent reply	other threads:[~2021-01-26  2:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210112075724.58561-1-zhuyan34@huawei.com>
2021-01-12  7:58 ` zhuyan (M)
2021-01-26  2:44   ` Rich Felker
2021-01-26 17:41     ` Rich Felker
2021-01-26  2:32 ` zhuyan (M) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19ad44ec8af24e8e8b70860f46438b19@huawei.com \
    --to=zhuyan34@huawei.com \
    --cc=chenzefeng2@huawei.com \
    --cc=liucheng32@huawei.com \
    --cc=musl@lists.openwall.com \
    --cc=zengweilin@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).