Blame SOURCES/0007-Avoiding-null-pointer-dereference.patch

449e93
From 2a352d36e2ecc3df4b1c2155b3fd2fa11f95e0bc Mon Sep 17 00:00:00 2001
449e93
From: klebertarcisio <klebertarcisio@yahoo.com.br>
449e93
Date: Fri, 2 Apr 2021 19:54:03 -0300
449e93
Subject: [PATCH 7/8] Avoiding null pointer dereference
449e93
449e93
---
449e93
 ctrl_iface.c   | 2 ++
449e93
 dcbtool_cmds.c | 2 ++
449e93
 lldp_8021qaz.c | 4 ++++
449e93
 lldp_dcbx.c    | 4 ++++
449e93
 4 files changed, 12 insertions(+)
449e93
449e93
diff --git a/ctrl_iface.c b/ctrl_iface.c
449e93
index 666f7c8..5f86fd2 100644
449e93
--- a/ctrl_iface.c
449e93
+++ b/ctrl_iface.c
449e93
@@ -180,6 +180,8 @@ int clif_iface_attach(struct clif_data *clifd,
449e93
 	} else {
449e93
 		tlv = strdup(ibuf);
449e93
 		str = tlv;
449e93
+		if (!str)
449e93
+			goto err_tlv;
449e93
 		str++;
449e93
 		/* Count number of TLV Modules */
449e93
 		tokenize = strtok(str, delim);
449e93
diff --git a/dcbtool_cmds.c b/dcbtool_cmds.c
449e93
index 0846f83..e1c76c4 100644
449e93
--- a/dcbtool_cmds.c
449e93
+++ b/dcbtool_cmds.c
449e93
@@ -373,6 +373,8 @@ int handle_dcb_cmds(struct clif *clif, int argc, char *argv[], int raw)
449e93
 	}
449e93
 
449e93
 	cmd_args = get_cmd_args();
449e93
+	if (!cmd_args)
449e93
+		return -1;
449e93
 
449e93
 	if (get_feature() == FEATURE_DCBX)
449e93
 		snprintf(cbuf, sizeof(cbuf), "%c%01x%02x%02x%s",
449e93
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
449e93
index 8bb2bc9..5fccbe4 100644
449e93
--- a/lldp_8021qaz.c
449e93
+++ b/lldp_8021qaz.c
449e93
@@ -1959,6 +1959,10 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
449e93
 	if (tlv->type == TYPE_1) {
449e93
 		clear_ieee8021qaz_rx(qaz_tlvs);
449e93
 		rx = malloc(sizeof(*rx));
449e93
+		if (!rx) {
449e93
+			LLDPAD_INFO("failed malloc for rx\n");
449e93
+			return TLV_ERR;
449e93
+		}
449e93
 		memset(rx, 0, sizeof(*rx));
449e93
 		qaz_tlvs->rx = rx;
449e93
 		qaz_tlvs->ieee8021qazdu = 0;
449e93
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
449e93
index 3567634..66df857 100644
449e93
--- a/lldp_dcbx.c
449e93
+++ b/lldp_dcbx.c
449e93
@@ -695,6 +695,10 @@ int dcbx_rchange(struct port *port, struct lldp_agent *agent, struct unpacked_tl
449e93
 	 */
449e93
 	if (tlv->type == TYPE_1) {
449e93
 		manifest = malloc(sizeof(*manifest));
449e93
+		if (!manifest) {
449e93
+			LLDPAD_INFO("failed malloc for manifest\n");
449e93
+			return TLV_ERR;
449e93
+		}
449e93
 		memset(manifest, 0, sizeof(*manifest));
449e93
 		dcbx->manifest = manifest;
449e93
 		dcbx->dcbdu = 0;
449e93
-- 
449e93
2.31.1
449e93