ACK: [PATCH 1/2] cpu: microcode: ensure we don't overflow with strncpy

Alex Hung alex.hung at canonical.com
Wed Nov 21 03:39:00 UTC 2012


On 11/07/2012 12:19 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/cpu/microcode/microcode.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/microcode/microcode.c b/src/cpu/microcode/microcode.c
> index 50b19e1..7d9a607 100644
> --- a/src/cpu/microcode/microcode.c
> +++ b/src/cpu/microcode/microcode.c
> @@ -75,7 +75,8 @@ static void gather_info(fwts_framework *fw, fwts_list *cpus)
>   					fwts_log_error(fw, "Cannot allocate memory.");
>   					break;
>   				}
> -				strncpy(cpu->cpu, entry->d_name, 16);
> +				strncpy(cpu->cpu, entry->d_name, sizeof(cpu->cpu) - 1);
> +				cpu->cpu[sizeof(cpu->cpu) - 1] = '\0';
>   				cpu->version = strtoul(data, NULL, 16);
>   				free(data);
>   				fwts_list_append(cpus, cpu);
>
Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list