diff mbox

lib: fwts_cpu: The string "flags" is 5 chars, fix incorrect strncmp size

Message ID 20170413101655.13603-1-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King April 13, 2017, 10:16 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently this string is being compared with a strncmp of size 4 bytes
instead of the correct string size of 5 bytes. Fix this.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Hung April 17, 2017, 5:30 p.m. UTC | #1
On 2017-04-13 03:16 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently this string is being compared with a strncmp of size 4 bytes
> instead of the correct string size of 5 bytes. Fix this.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index 148857e4..90bae200 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -160,7 +160,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
>  			sscanf(ptr, "%d", &cpu->stepping);
>  			continue;
>  		}
> -		if (!strncmp(buffer, "flags", 4)) {
> +		if (!strncmp(buffer, "flags", 5)) {
>  			cpu->flags = strdup(ptr);
>  			continue;
>  		}
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu April 21, 2017, 2:48 a.m. UTC | #2
On 04/13/2017 06:16 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently this string is being compared with a strncmp of size 4 bytes
> instead of the correct string size of 5 bytes. Fix this.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
> index 148857e4..90bae200 100644
> --- a/src/lib/src/fwts_cpu.c
> +++ b/src/lib/src/fwts_cpu.c
> @@ -160,7 +160,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
>  			sscanf(ptr, "%d", &cpu->stepping);
>  			continue;
>  		}
> -		if (!strncmp(buffer, "flags", 4)) {
> +		if (!strncmp(buffer, "flags", 5)) {
>  			cpu->flags = strdup(ptr);
>  			continue;
>  		}
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index 148857e4..90bae200 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -160,7 +160,7 @@  fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
 			sscanf(ptr, "%d", &cpu->stepping);
 			continue;
 		}
-		if (!strncmp(buffer, "flags", 4)) {
+		if (!strncmp(buffer, "flags", 5)) {
 			cpu->flags = strdup(ptr);
 			continue;
 		}