DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] power: fix sprintf with snprintf
@ 2019-02-04  7:24 Pallantla Poornima
  2019-02-08 21:28 ` Aaron Conole
  0 siblings, 1 reply; 2+ messages in thread
From: Pallantla Poornima @ 2019-02-04  7:24 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: 450f079131 ("power: add traffic pattern aware power control")
Cc: stable@dpdk.org

Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
---
 lib/librte_power/rte_power_empty_poll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_power/rte_power_empty_poll.c b/lib/librte_power/rte_power_empty_poll.c
index e6145462f..df00a3968 100644
--- a/lib/librte_power/rte_power_empty_poll.c
+++ b/lib/librte_power/rte_power_empty_poll.c
@@ -159,7 +159,7 @@ update_training_stats(struct priority_worker *poll_stats,
 	char pfi_str[32];
 	uint64_t p0_empty_deq;
 
-	sprintf(pfi_str, "%02d", freq);
+	snprintf(pfi_str, sizeof(pfi_str), "%02d", freq);
 
 	if (poll_stats->cur_freq == freq &&
 			poll_stats->thresh[freq].trained == false) {
-- 
2.17.2

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

* Re: [dpdk-dev] [PATCH] power: fix sprintf with snprintf
  2019-02-04  7:24 [dpdk-dev] [PATCH] power: fix sprintf with snprintf Pallantla Poornima
@ 2019-02-08 21:28 ` Aaron Conole
  0 siblings, 0 replies; 2+ messages in thread
From: Aaron Conole @ 2019-02-08 21:28 UTC (permalink / raw)
  To: Pallantla Poornima; +Cc: dev, reshma.pattan, david.hunt, stable

Pallantla Poornima <pallantlax.poornima@intel.com> writes:

> sprintf function is not secure as it doesn't check the length of string.
> More secure function snprintf is used.
>
> Fixes: 450f079131 ("power: add traffic pattern aware power control")
> Cc: stable@dpdk.org
>
> Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
> ---
>  lib/librte_power/rte_power_empty_poll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_power/rte_power_empty_poll.c b/lib/librte_power/rte_power_empty_poll.c
> index e6145462f..df00a3968 100644
> --- a/lib/librte_power/rte_power_empty_poll.c
> +++ b/lib/librte_power/rte_power_empty_poll.c
> @@ -159,7 +159,7 @@ update_training_stats(struct priority_worker *poll_stats,
>  	char pfi_str[32];
>  	uint64_t p0_empty_deq;
>  
> -	sprintf(pfi_str, "%02d", freq);
> +	snprintf(pfi_str, sizeof(pfi_str), "%02d", freq);

Shouldn't we just remove pfi_str completely?  I don't see it referenced
anywhere else in this function.

That would be better than changing to snprintf(), imo.

>  	if (poll_stats->cur_freq == freq &&
>  			poll_stats->thresh[freq].trained == false) {

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

end of thread, other threads:[~2019-02-08 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04  7:24 [dpdk-dev] [PATCH] power: fix sprintf with snprintf Pallantla Poornima
2019-02-08 21:28 ` Aaron Conole

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