DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf
@ 2019-02-06 10:39 Pallantla Poornima
  2019-02-06 10:48 ` Bruce Richardson
  0 siblings, 1 reply; 2+ messages in thread
From: Pallantla Poornima @ 2019-02-06 10:39 UTC (permalink / raw)
  To: dev; +Cc: reshma.pattan, david.hunt, Pallantla Poornima, stable

sprintf function is not secure as it doesn't check the length of string.
More secure function snprintf is used.

Fixes: f74df2c57e ("test/distributor: test single and burst API")
Cc: stable@dpdk.org

Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
---
 test/test/test_distributor.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c
index 98919ec0c..03df32b05 100644
--- a/test/test/test_distributor.c
+++ b/test/test/test_distributor.c
@@ -642,9 +642,11 @@ test_distributor(void)
 
 		worker_params.dist = dist[i];
 		if (i)
-			sprintf(worker_params.name, "burst");
+			snprintf(worker_params.name,
+					sizeof(worker_params.name), "burst");
 		else
-			sprintf(worker_params.name, "single");
+			snprintf(worker_params.name,
+					sizeof(worker_params.name), "single");
 
 		rte_eal_mp_remote_launch(handle_work,
 				&worker_params, SKIP_MASTER);
-- 
2.17.2

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

* Re: [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf
  2019-02-06 10:39 [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf Pallantla Poornima
@ 2019-02-06 10:48 ` Bruce Richardson
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Richardson @ 2019-02-06 10:48 UTC (permalink / raw)
  To: Pallantla Poornima; +Cc: dev, reshma.pattan, david.hunt, stable

On Wed, Feb 06, 2019 at 10:39:07AM +0000, Pallantla Poornima wrote:
> sprintf function is not secure as it doesn't check the length of string.
> More secure function snprintf is used.
> 
> Fixes: f74df2c57e ("test/distributor: test single and burst API")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
> ---
>  test/test/test_distributor.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c
> index 98919ec0c..03df32b05 100644
> --- a/test/test/test_distributor.c
> +++ b/test/test/test_distributor.c
> @@ -642,9 +642,11 @@ test_distributor(void)
>  
>  		worker_params.dist = dist[i];
>  		if (i)
> -			sprintf(worker_params.name, "burst");
> +			snprintf(worker_params.name,
> +					sizeof(worker_params.name), "burst");
>  		else
> -			sprintf(worker_params.name, "single");
> +			snprintf(worker_params.name,
> +					sizeof(worker_params.name), "single");
>  
>  		rte_eal_mp_remote_launch(handle_work,
>  				&worker_params, SKIP_MASTER);
> -- 
While not wrong here, I think changing these to string copies using
"strlcpy" might be better, since this is constant text in each case, and no
printf formatting is actually needed.

/Bruce

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

end of thread, other threads:[~2019-02-06 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 10:39 [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf Pallantla Poornima
2019-02-06 10:48 ` 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).