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@xxxxxxxxx> --- 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