linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: linux-sctp@vger.kernel.org
Subject: [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter
Date: Thu, 22 Apr 2021 16:36:18 -0300	[thread overview]
Message-ID: <0394d84584498d5551c5e630500a2cbb48491dc4.1619119690.git.marcelo.leitner@gmail.com> (raw)
In-Reply-To: <cover.1619119690.git.marcelo.leitner@gmail.com>

CovScan noticed that outmsg.msg_flags was being used uninitialized
if sinfo was not provided. Lets fix it by initializing it with the flags
parameter, like sctp_sendv does.

Fixes: 91239acfc91f ("Add sctp_send() API support and testcases")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
 src/lib/sendmsg.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/lib/sendmsg.c b/src/lib/sendmsg.c
index 4c90b0757f4bb1a337de44cfa974a356fef031e6..c2bd51029964f3bf05a512ea61d479c086f6088c 100644
--- a/src/lib/sendmsg.c
+++ b/src/lib/sendmsg.c
@@ -77,25 +77,21 @@ int
 sctp_send(int s, const void *msg, size_t len,
           const struct sctp_sndrcvinfo *sinfo, int flags)
 {
-	struct msghdr outmsg;
+	struct msghdr outmsg = {};
 	struct iovec iov;
 	char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
 
-	outmsg.msg_name = NULL;
-	outmsg.msg_namelen = 0;
 	outmsg.msg_iov = &iov;
 	iov.iov_base = (void *)msg;
 	iov.iov_len = len;
 	outmsg.msg_iovlen = 1;
-	outmsg.msg_control = NULL;
-	outmsg.msg_controllen = 0;
+	outmsg.msg_flags = flags;
 
 	if (sinfo) {	
 		struct cmsghdr *cmsg;
 
 		outmsg.msg_control = outcmsg;
 		outmsg.msg_controllen = sizeof(outcmsg);
-		outmsg.msg_flags = 0;
 
 		cmsg = CMSG_FIRSTHDR(&outmsg);
 		cmsg->cmsg_level = IPPROTO_SCTP;
-- 
2.30.2


  reply	other threads:[~2021-04-22 19:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 19:36 [PATCH lksctp-tools 0/2] sctp_send/v fixes Marcelo Ricardo Leitner
2021-04-22 19:36 ` Marcelo Ricardo Leitner [this message]
2021-04-22 19:36 ` [PATCH lksctp-tools 2/2] sctp_sendv: avoid explicit memset for var initialization Marcelo Ricardo Leitner
2021-04-24 17:46 ` [PATCH lksctp-tools 0/2] sctp_send/v fixes Xin Long

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=0394d84584498d5551c5e630500a2cbb48491dc4.1619119690.git.marcelo.leitner@gmail.com \
    --to=marcelo.leitner@gmail.com \
    --cc=linux-sctp@vger.kernel.org \
    /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.
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).