[dpdk-stable] patch 'app/procinfo: use strlcpy for copying string' has been queued to LTS release 18.11.6

Kevin Traynor ktraynor at redhat.com
Tue Dec 10 15:59:14 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/16/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/bc12c8f6136f2516e98027be0e5e8a3df6f7c01a

Thanks.

Kevin.

---
>From bc12c8f6136f2516e98027be0e5e8a3df6f7c01a Mon Sep 17 00:00:00 2001
From: Ciara Power <ciara.power at intel.com>
Date: Thu, 26 Sep 2019 16:11:59 +0100
Subject: [PATCH] app/procinfo: use strlcpy for copying string

[ upstream commit 7edbf7ddfd7d2453afaad3b72666491d30b616af ]

Replaced strncpy and strcpy with strlcpy.
Also replaced snprintf with strlcpy where applicable.
Using strlcpy is safe practice when copying strings, as it will include
a null terminator.

Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")

Reported-by: Reshma Pattan <reshma.pattan at intel.com>
Signed-off-by: Ciara Power <ciara.power at intel.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 app/proc-info/main.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index c20effa4f..248f0b2b0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -168,5 +168,5 @@ proc_info_preparse_args(int argc, char **argv)
 
 		if (err)
-			strcpy(host_id, "unknown");
+			strlcpy(host_id, "unknown", sizeof(host_id));
 	}
 
@@ -335,48 +335,48 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
 	    (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
 		if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
-			strncpy(cnt_type, "if_rx_errors", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
 		else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
-			strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_dropped", cnt_type_len);
 		else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
-			strncpy(cnt_type, "if_rx_octets", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_octets", cnt_type_len);
 		else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
-			strncpy(cnt_type, "if_rx_packets", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_packets", cnt_type_len);
 		else if (strncmp(type_end, "_placement",
 				 strlen("_placement")) == 0)
-			strncpy(cnt_type, "if_rx_errors", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
 		else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
-			strncpy(cnt_type, "if_rx_errors", cnt_type_len);
+			strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
 		else
 			/* Does not fit obvious type: use a more generic one */
-			strncpy(cnt_type, "derive", cnt_type_len);
+			strlcpy(cnt_type, "derive", cnt_type_len);
 	} else if ((type_end != NULL) &&
 		(strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
 		if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
-			strncpy(cnt_type, "if_tx_errors", cnt_type_len);
+			strlcpy(cnt_type, "if_tx_errors", cnt_type_len);
 		else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
-			strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
+			strlcpy(cnt_type, "if_tx_dropped", cnt_type_len);
 		else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
-			strncpy(cnt_type, "if_tx_octets", cnt_type_len);
+			strlcpy(cnt_type, "if_tx_octets", cnt_type_len);
 		else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
-			strncpy(cnt_type, "if_tx_packets", cnt_type_len);
+			strlcpy(cnt_type, "if_tx_packets", cnt_type_len);
 		else
 			/* Does not fit obvious type: use a more generic one */
-			strncpy(cnt_type, "derive", cnt_type_len);
+			strlcpy(cnt_type, "derive", cnt_type_len);
 	} else if ((type_end != NULL) &&
 		   (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
 		if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
-			strncpy(cnt_type, "operations", cnt_type_len);
+			strlcpy(cnt_type, "operations", cnt_type_len);
 		else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
-			strncpy(cnt_type, "errors", cnt_type_len);
+			strlcpy(cnt_type, "errors", cnt_type_len);
 		else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
-			strncpy(cnt_type, "filter_result", cnt_type_len);
+			strlcpy(cnt_type, "filter_result", cnt_type_len);
 	} else if ((type_end != NULL) &&
 		   (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
 		if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
-			strncpy(cnt_type, "errors", cnt_type_len);
+			strlcpy(cnt_type, "errors", cnt_type_len);
 	} else {
 		/* Does not fit obvious type, or strrchr error: */
 		/* use a more generic type */
-		strncpy(cnt_type, "derive", cnt_type_len);
+		strlcpy(cnt_type, "derive", cnt_type_len);
 	}
 }
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-10 14:49:41.783104698 +0000
+++ 0040-app-procinfo-use-strlcpy-for-copying-string.patch	2019-12-10 14:49:39.071457413 +0000
@@ -1 +1 @@
-From 7edbf7ddfd7d2453afaad3b72666491d30b616af Mon Sep 17 00:00:00 2001
+From bc12c8f6136f2516e98027be0e5e8a3df6f7c01a Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 7edbf7ddfd7d2453afaad3b72666491d30b616af ]
+
@@ -13 +14,0 @@
-Cc: stable at dpdk.org
@@ -19,2 +20,2 @@
- app/proc-info/main.c | 38 +++++++++++++++++++-------------------
- 1 file changed, 19 insertions(+), 19 deletions(-)
+ app/proc-info/main.c | 36 ++++++++++++++++++------------------
+ 1 file changed, 18 insertions(+), 18 deletions(-)
@@ -23 +24 @@
-index 8cf501d06..abeca4aab 100644
+index c20effa4f..248f0b2b0 100644
@@ -26 +27 @@
-@@ -204,5 +204,5 @@ proc_info_preparse_args(int argc, char **argv)
+@@ -168,5 +168,5 @@ proc_info_preparse_args(int argc, char **argv)
@@ -33 +34 @@
-@@ -399,48 +399,48 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
+@@ -335,48 +335,48 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
@@ -99,7 +99,0 @@
-@@ -1350,5 +1350,5 @@ main(int argc, char **argv)
- 		printf("Error from rte_eal_cleanup(), %d\n", ret);
- 
--	snprintf(bdr_str, MAX_STRING_LEN, " ");
-+	strlcpy(bdr_str, " ", MAX_STRING_LEN);
- 	STATS_BDR_STR(50, bdr_str);
- 



More information about the stable mailing list