[PATCH] lib: fwts_arch: set len to 1 to ensure space for '\0'
Colin King
colin.king at canonical.com
Sat Jun 4 15:29:55 UTC 2016
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);
--
2.8.1
More information about the fwts-devel
mailing list