[PATCH 6/8] global: make sure that bulk config string is null-terminated
Jussi Kivilinna
jussi.kivilinna at iki.fi
Sun Jan 31 17:01:38 CET 2021
* src/global.c (_gcry_get_config): Append null-terminator to output
in the 'what == NULL' case.
--
Config string was not being explicitly null-terminated which resulted
garbage output from tests/version with ASAN enabled builds.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
src/global.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/global.c b/src/global.c
index 57f7329b..8940cea0 100644
--- a/src/global.c
+++ b/src/global.c
@@ -434,6 +434,13 @@ _gcry_get_config (int mode, const char *what)
return NULL;
print_config (what, fp);
+
+ if (!what)
+ {
+ /* Null-terminate bulk output. */
+ gpgrt_fwrite ("\0", 1, 1, fp);
+ }
+
if (gpgrt_ferror (fp))
{
save_errno = errno;
--
2.27.0
More information about the Gcrypt-devel
mailing list