From: Jeremy Allison Date: Wed, 8 Jun 2016 12:34:20 +0000 (+0200) Subject: lib: Fix uninitialized read in msghdr_copy X-Git-Tag: tdb-1.3.10~904 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e2711b2a0adeda6873f9c8161b9b01a56ae7098;p=thirdparty%2Fsamba.git lib: Fix uninitialized read in msghdr_copy Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Jun 8 18:34:27 CEST 2016 on sn-devel-144 --- diff --git a/lib/util/msghdr.c b/lib/util/msghdr.c index 1aeadfc8d4d..0100b33e1f2 100644 --- a/lib/util/msghdr.c +++ b/lib/util/msghdr.c @@ -204,7 +204,14 @@ ssize_t msghdr_copy(struct msghdr_buf *msg, size_t msgsize, bufsize = (msgsize > offsetof(struct msghdr_buf, buf)) ? msgsize - offsetof(struct msghdr_buf, buf) : 0; - fd_len = msghdr_prep_fds(&msg->msg, msg->buf, bufsize, fds, num_fds); + if (msg != NULL) { + msg->msg = (struct msghdr) {}; + + fd_len = msghdr_prep_fds(&msg->msg, msg->buf, bufsize, + fds, num_fds); + } else { + fd_len = msghdr_prep_fds(NULL, NULL, bufsize, fds, num_fds); + } if (fd_len == -1) { return -1;