patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] app/procinfo: fix strncpy count issue
@ 2018-02-20 12:57 Radu Nicolau
  2018-02-20 13:00 ` [dpdk-stable] [PATCH v2] " Radu Nicolau
  2018-02-20 13:29 ` [dpdk-stable] [dpdk-dev] [PATCH] " Bruce Richardson
  0 siblings, 2 replies; 6+ messages in thread
From: Radu Nicolau @ 2018-02-20 12:57 UTC (permalink / raw)
  To: dev; +Cc: john.mcnamara, maryam.tahhan, reshma.pattan, Radu Nicolau, stable

Change strncpy count parameter to MAX_LONG_OPT_SZ-1 to avoid
overwriting the last NULL character and for consistency.

Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Coverity issue: 30688

Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 app/proc_info/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 2f53e3c..5f0b745 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -159,7 +159,7 @@ proc_info_preparse_args(int argc, char **argv)
 				proc_info_usage(prgname);
 				return -1;
 			}
-			strncpy(host_id, argv[i+1], sizeof(host_id));
+			strncpy(host_id, argv[i+1], MAX_LONG_OPT_SZ-1);
 		}
 	}
 
-- 
2.7.5

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

* [dpdk-stable] [PATCH v2] app/procinfo: fix strncpy count issue
  2018-02-20 12:57 [dpdk-stable] [PATCH] app/procinfo: fix strncpy count issue Radu Nicolau
@ 2018-02-20 13:00 ` Radu Nicolau
  2018-02-20 13:52   ` [dpdk-stable] [PATCH v3] " Radu Nicolau
  2018-02-20 13:29 ` [dpdk-stable] [dpdk-dev] [PATCH] " Bruce Richardson
  1 sibling, 1 reply; 6+ messages in thread
From: Radu Nicolau @ 2018-02-20 13:00 UTC (permalink / raw)
  To: dev; +Cc: john.mcnamara, maryam.tahhan, reshma.pattan, Radu Nicolau, stable

Change strncpy count parameter to MAX_LONG_OPT_SZ-1 to avoid
overwriting the last NULL character and for consistency.

Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Coverity issue: 143252

Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
v2: corrected coverity issue id

 app/proc_info/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 2f53e3c..5f0b745 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -159,7 +159,7 @@ proc_info_preparse_args(int argc, char **argv)
 				proc_info_usage(prgname);
 				return -1;
 			}
-			strncpy(host_id, argv[i+1], sizeof(host_id));
+			strncpy(host_id, argv[i+1], MAX_LONG_OPT_SZ-1);
 		}
 	}
 
-- 
2.7.5

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] app/procinfo: fix strncpy count issue
  2018-02-20 12:57 [dpdk-stable] [PATCH] app/procinfo: fix strncpy count issue Radu Nicolau
  2018-02-20 13:00 ` [dpdk-stable] [PATCH v2] " Radu Nicolau
@ 2018-02-20 13:29 ` Bruce Richardson
  1 sibling, 0 replies; 6+ messages in thread
From: Bruce Richardson @ 2018-02-20 13:29 UTC (permalink / raw)
  To: Radu Nicolau; +Cc: dev, john.mcnamara, maryam.tahhan, reshma.pattan, stable

On Tue, Feb 20, 2018 at 12:57:36PM +0000, Radu Nicolau wrote:
> Change strncpy count parameter to MAX_LONG_OPT_SZ-1 to avoid
> overwriting the last NULL character and for consistency.
> 
> Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
> Coverity issue: 30688
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
strncpy is a very nasty function that is easy to get wrong. Rather than
fixing it's off by one errors, I think a better fix is to use snprintf
as is done in most other places.

/Bruce

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

* [dpdk-stable] [PATCH v3] app/procinfo: fix strncpy count issue
  2018-02-20 13:00 ` [dpdk-stable] [PATCH v2] " Radu Nicolau
@ 2018-02-20 13:52   ` Radu Nicolau
  2018-02-20 14:16     ` Bruce Richardson
  0 siblings, 1 reply; 6+ messages in thread
From: Radu Nicolau @ 2018-02-20 13:52 UTC (permalink / raw)
  To: dev
  Cc: john.mcnamara, maryam.tahhan, reshma.pattan, bruce.richardson,
	Radu Nicolau, stable

Replace strncpy with snprintf to avoid overwriting the last
NULL character.

Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Coverity issue: 143252

Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
v3: replaced strncpy with snprintf

 app/proc_info/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 2f53e3c..f90c144 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -159,7 +159,7 @@ proc_info_preparse_args(int argc, char **argv)
 				proc_info_usage(prgname);
 				return -1;
 			}
-			strncpy(host_id, argv[i+1], sizeof(host_id));
+			snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
 		}
 	}
 
-- 
2.7.5

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

* Re: [dpdk-stable] [PATCH v3] app/procinfo: fix strncpy count issue
  2018-02-20 13:52   ` [dpdk-stable] [PATCH v3] " Radu Nicolau
@ 2018-02-20 14:16     ` Bruce Richardson
  2018-03-27 22:25       ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Richardson @ 2018-02-20 14:16 UTC (permalink / raw)
  To: Radu Nicolau; +Cc: dev, john.mcnamara, maryam.tahhan, reshma.pattan, stable

On Tue, Feb 20, 2018 at 01:52:22PM +0000, Radu Nicolau wrote:
> Replace strncpy with snprintf to avoid overwriting the last
> NULL character.
> 
> Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
> Coverity issue: 143252
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [dpdk-stable] [PATCH v3] app/procinfo: fix strncpy count issue
  2018-02-20 14:16     ` Bruce Richardson
@ 2018-03-27 22:25       ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-03-27 22:25 UTC (permalink / raw)
  To: Radu Nicolau
  Cc: stable, Bruce Richardson, dev, john.mcnamara, maryam.tahhan,
	reshma.pattan

20/02/2018 15:16, Bruce Richardson:
> On Tue, Feb 20, 2018 at 01:52:22PM +0000, Radu Nicolau wrote:
> > Replace strncpy with snprintf to avoid overwriting the last
> > NULL character.
> > 
> > Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
> > Coverity issue: 143252
> > 
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> > ---
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks

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

end of thread, other threads:[~2018-03-27 22:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 12:57 [dpdk-stable] [PATCH] app/procinfo: fix strncpy count issue Radu Nicolau
2018-02-20 13:00 ` [dpdk-stable] [PATCH v2] " Radu Nicolau
2018-02-20 13:52   ` [dpdk-stable] [PATCH v3] " Radu Nicolau
2018-02-20 14:16     ` Bruce Richardson
2018-03-27 22:25       ` Thomas Monjalon
2018-02-20 13:29 ` [dpdk-stable] [dpdk-dev] [PATCH] " Bruce Richardson

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