ACK: [PATCH] lib: fwts_arch: set len to 1 to ensure space for '\0'

ivanhu ivan.hu at canonical.com
Wed Jun 8 07:06:36 UTC 2016



On 2016年06月04日 23:29, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> The current code just allocates enough space for the strings
> with a trailing spaces, and not enough space for the terminating
> '\0' character.  Set len to 1 to ensure we have enough space
> allocated.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_arch.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_arch.c b/src/lib/src/fwts_arch.c
> index 1fe3843..6456604 100644
> --- a/src/lib/src/fwts_arch.c
> +++ b/src/lib/src/fwts_arch.c
> @@ -77,7 +77,7 @@ const char *fwts_arch_names(void)
>   	if (arch_names)
>   		return arch_names;
>
> -	for (ptr = arch_info, len = 0; ptr->arch != FWTS_ARCH_OTHER; ptr++)
> +	for (ptr = arch_info, len = 1; ptr->arch != FWTS_ARCH_OTHER; ptr++)
>   		len += strlen(ptr->name) + 1;
>
>   	arch_names = calloc(len, 1);
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list