examples/vm_power_manager: fix string null termination

Message ID 20190409160024.40431-1-reshma.pattan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series examples/vm_power_manager: fix string null termination |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Pattan, Reshma April 9, 2019, 4 p.m. UTC
  After the read() the jason_data null termination is missing
for the case "indent < 0", for "indent > 0" and "indent == 0"
cases null termination is already handled.

So add the missing case "indent < 0" to the existing "indent == 0"
case to fix null termination.

Coverity issue: 337680
Fixes: a63504a90f ("examples/power: add JSON string handling")
CC: david.hunt@intel.com
CC: stable@dpdk.org

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 examples/vm_power_manager/channel_monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Hunt, David April 15, 2019, 2:50 p.m. UTC | #1
On 9/4/2019 5:00 PM, Reshma Pattan wrote:
> After the read() the jason_data null termination is missing
> for the case "indent < 0", for "indent > 0" and "indent == 0"
> cases null termination is already handled.
>
> So add the missing case "indent < 0" to the existing "indent == 0"
> case to fix null termination.
>
> Coverity issue: 337680
> Fixes: a63504a90f ("examples/power: add JSON string handling")
> CC: david.hunt@intel.com
> CC: stable@dpdk.org
>
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
>   examples/vm_power_manager/channel_monitor.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
> index 74df0fe20..c67ca4710 100644
> --- a/examples/vm_power_manager/channel_monitor.c
> +++ b/examples/vm_power_manager/channel_monitor.c
> @@ -807,7 +807,7 @@ read_json_packet(struct channel_info *chan_info)
>   				indent--;
>   			if ((indent > 0) || (idx > 0))
>   				idx++;
> -			if (indent == 0)
> +			if (indent <= 0)
>   				json_data[idx] = 0;
>   			if (idx >= MAX_JSON_STRING_LEN-1)
>   				break;


Acked-by: David Hunt <david.hunt@intel.com>
  
Thomas Monjalon April 22, 2019, 9:13 p.m. UTC | #2
15/04/2019 16:50, Hunt, David:
> On 9/4/2019 5:00 PM, Reshma Pattan wrote:
> > After the read() the jason_data null termination is missing
> > for the case "indent < 0", for "indent > 0" and "indent == 0"
> > cases null termination is already handled.
> >
> > So add the missing case "indent < 0" to the existing "indent == 0"
> > case to fix null termination.
> >
> > Coverity issue: 337680
> > Fixes: a63504a90f ("examples/power: add JSON string handling")
> > CC: david.hunt@intel.com
> > CC: stable@dpdk.org
> >
> > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> 
> Acked-by: David Hunt <david.hunt@intel.com>

Applied, thanks
  

Patch

diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
index 74df0fe20..c67ca4710 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -807,7 +807,7 @@  read_json_packet(struct channel_info *chan_info)
 				indent--;
 			if ((indent > 0) || (idx > 0))
 				idx++;
-			if (indent == 0)
+			if (indent <= 0)
 				json_data[idx] = 0;
 			if (idx >= MAX_JSON_STRING_LEN-1)
 				break;