regression_8100: use null terminated strings with file_to_c
GCC 9 is more strict with string manipulation, causing the build to
fail as the string data converted via file_to_c is not null terminated,
as described by the following build error:
regression_8100.c:100:29: error: '%*s' directive argument is not a
nul-terminated string [-Werror=format-overflow=]
tlen = myasprintf(&trust, "%*s", (int)sizeof(regression_8100_ca_crt),
^~~
regression_8100_ca_crt);
~~~~~~~~~~~~~~~~~~~~~~
Change file_to_c to terminate the string after conversion and update the
string size to remove the null terminated byte. Also update
regression_8100 to use the size variable defined via file_to_c instead
of manually calling sizeof.
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/scripts/file_to_c.py b/scripts/file_to_c.py
index 83a9832..ae16f52 100755
--- a/scripts/file_to_c.py
+++ b/scripts/file_to_c.py
@@ -37,9 +37,9 @@
else:
f.write(" ")
- f.write("};\n")
+ f.write("'\\0'};\n")
f.write("const size_t " + args.name + "_size = sizeof(" +
- args.name + ");\n")
+ args.name + ") - 1;\n")
f.close()
inf.close()