linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH lksctp-tools 0/2] sctp_send/v fixes
@ 2021-04-22 19:36 Marcelo Ricardo Leitner
  2021-04-22 19:36 ` [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter Marcelo Ricardo Leitner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-04-22 19:36 UTC (permalink / raw)
  To: linux-sctp

First one is more important. Identified by CovScan.
2nd patch is just a cosmetic change.

Marcelo Ricardo Leitner (2):
  sctp_send: fix ignored flags parameter
  sctp_sendv: avoid explicit memset for var initialization

 src/lib/sendmsg.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter
  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
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-04-22 19:36 UTC (permalink / raw)
  To: linux-sctp

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH lksctp-tools 2/2] sctp_sendv: avoid explicit memset for var initialization
  2021-04-22 19:36 [PATCH lksctp-tools 0/2] sctp_send/v fixes Marcelo Ricardo Leitner
  2021-04-22 19:36 ` [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter Marcelo Ricardo Leitner
@ 2021-04-22 19:36 ` Marcelo Ricardo Leitner
  2021-04-24 17:46 ` [PATCH lksctp-tools 0/2] sctp_send/v fixes Xin Long
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-04-22 19:36 UTC (permalink / raw)
  To: linux-sctp

Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
 src/lib/sendmsg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/lib/sendmsg.c b/src/lib/sendmsg.c
index c2bd51029964f3bf05a512ea61d479c086f6088c..bee492134e30cbc41ecfce7117444d17c8ab9089 100644
--- a/src/lib/sendmsg.c
+++ b/src/lib/sendmsg.c
@@ -125,14 +125,12 @@ int sctp_sendv(int s, const struct iovec *iov, int iovcnt,
 {
 	char _cmsg[CMSG_SPACE(sizeof(struct sctp_sendv_spa))];
 	struct cmsghdr *cmsg = (struct cmsghdr *)_cmsg;
+	struct msghdr outmsg = {};
 	struct sockaddr *addr;
-	struct msghdr outmsg;
 	int len, cmsglen = 0;
 	int err, type, i;
 	char *addrbuf;
 
-	/* set msg_iov, msg_iovlen, msg_flags */
-	memset(&outmsg, 0x00, sizeof(outmsg));
 	outmsg.msg_iov = (struct iovec *)iov;
 	outmsg.msg_iovlen = iovcnt;
 	outmsg.msg_flags = flags;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH lksctp-tools 0/2] sctp_send/v fixes
  2021-04-22 19:36 [PATCH lksctp-tools 0/2] sctp_send/v fixes Marcelo Ricardo Leitner
  2021-04-22 19:36 ` [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter Marcelo Ricardo Leitner
  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 ` Xin Long
  2 siblings, 0 replies; 4+ messages in thread
From: Xin Long @ 2021-04-24 17:46 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner; +Cc: linux-sctp @ vger . kernel . org

On Thu, Apr 22, 2021 at 3:36 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> First one is more important. Identified by CovScan.
> 2nd patch is just a cosmetic change.
>
> Marcelo Ricardo Leitner (2):
>   sctp_send: fix ignored flags parameter
>   sctp_sendv: avoid explicit memset for var initialization
>
>  src/lib/sendmsg.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> --
> 2.30.2
>
Series Reviewed-by: Xin Long <lucien.xin@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-24 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 19:36 [PATCH lksctp-tools 0/2] sctp_send/v fixes Marcelo Ricardo Leitner
2021-04-22 19:36 ` [PATCH lksctp-tools 1/2] sctp_send: fix ignored flags parameter Marcelo Ricardo Leitner
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

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).