[PATCH lksctp-tools] sctp_test: check strdup return in append_addr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     SCTP

  Powered by Linux