Home GnuPG

global: make sure that bulk config string is null-terminated

Description

global: make sure that bulk config string is null-terminated

* 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@iki.fi>

Details

Provenance
jukiviliAuthored on Jan 31 2021, 3:59 PM
Parents
rCa71b7de32b0c: Add handling for -Og with O-flag munging
Branches
Unknown
Tags
Unknown

Event Timeline

Actually I can't see why this is only a problem in the NULL case. if you select a specific config item the string might also not be 0 terminated - it depends a bit on the size of the used buffers. In 1.8 I applied this with the the if (!what) condidion.

The 'what != NULL' case is handled by the "Strip trailing LF" part at the end of function. These data strings always end with '\n', so null-termination gets done there.

Oh well, a bit surprising but I agree that it works :-)