Blame SOURCES/0003-libibnetdisc-fix-printing-a-possibly-non-NUL-termina.patch

87b28f
From 45fcc7ad41216a93bafb452f7d7a4507d52722cd Mon Sep 17 00:00:00 2001
87b28f
From: Michal Schmidt <mschmidt@redhat.com>
87b28f
Date: Wed, 1 Feb 2023 23:30:52 +0100
87b28f
Subject: [PATCH 3/3] libibnetdisc: fix printing a possibly non-NUL-terminated
87b28f
 string
87b28f
87b28f
Found by a static check (covscan).
87b28f
87b28f
Fixes: d974c4e398d2 ("Fix max length of node description (ibnetdiscover and smpquery)")
87b28f
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
87b28f
---
87b28f
 libibnetdisc/chassis.c | 3 ++-
87b28f
 1 file changed, 2 insertions(+), 1 deletion(-)
87b28f
87b28f
diff --git a/libibnetdisc/chassis.c b/libibnetdisc/chassis.c
87b28f
index a3ec1d82807c..bc1a8aff8acb 100644
87b28f
--- a/libibnetdisc/chassis.c
87b28f
+++ b/libibnetdisc/chassis.c
87b28f
@@ -597,7 +597,7 @@ static int fill_mellanox_chassis_record(ibnd_node_t * node)
87b28f
 	int p = 0;
87b28f
 	ibnd_port_t *port;
87b28f
 
87b28f
-	char node_desc[IB_SMP_DATA_SIZE];
87b28f
+	char node_desc[IB_SMP_DATA_SIZE + 1];
87b28f
 	char *system_name;
87b28f
 	char *system_type;
87b28f
 	char *system_slot_name;
87b28f
@@ -617,6 +617,7 @@ static int fill_mellanox_chassis_record(ibnd_node_t * node)
87b28f
 	 */
87b28f
 
87b28f
 	memcpy(node_desc, node->nodedesc, IB_SMP_DATA_SIZE);
87b28f
+	node_desc[IB_SMP_DATA_SIZE] = '\0';
87b28f
 
87b28f
 	IBND_DEBUG("fill_mellanox_chassis_record: node_desc:%s \n",node_desc);
87b28f
 
87b28f
-- 
87b28f
2.39.1
87b28f