linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH lksctp-tools] sctp_test: check strdup return in append_addr
@ 2021-11-24 15:55 Xin Long
  2021-12-07 18:09 ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2021-11-24 15:55 UTC (permalink / raw)
  To: linux-sctp; +Cc: Marcelo Ricardo Leitner

strdup() may return NULL in append_addr(), and we should do the
check for its return value before operating it.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 src/apps/sctp_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/apps/sctp_test.c b/src/apps/sctp_test.c
index e382804..59fd4ad 100644
--- a/src/apps/sctp_test.c
+++ b/src/apps/sctp_test.c
@@ -499,6 +499,9 @@ append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
 	char *ifname;
 	int ifindex = 0;
 
+	if (!ipaddr)
+		return NULL;
+
 	/* check the interface. */
 	ifname = strchr(ipaddr,'%');
 	if (ifname) {
-- 
2.27.0


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

* Re: [PATCH lksctp-tools] sctp_test: check strdup return in append_addr
  2021-11-24 15:55 [PATCH lksctp-tools] sctp_test: check strdup return in append_addr Xin Long
@ 2021-12-07 18:09 ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-12-07 18:09 UTC (permalink / raw)
  To: Xin Long; +Cc: linux-sctp

On Wed, Nov 24, 2021 at 10:55:24AM -0500, Xin Long wrote:
> strdup() may return NULL in append_addr(), and we should do the
> check for its return value before operating it.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Applied. Thanks.

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

end of thread, other threads:[~2021-12-07 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 15:55 [PATCH lksctp-tools] sctp_test: check strdup return in append_addr Xin Long
2021-12-07 18:09 ` Marcelo Ricardo Leitner

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