diff options
author | Werner Koch <[email protected]> | 2020-08-21 09:28:08 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-08-21 09:30:38 +0000 |
commit | 33fd55ca6f3efc50c260469179788e9f725ddc58 (patch) | |
tree | 366e39192a32752a1963a3bec060b23a1d72b6ea /common/stringhelp.c | |
parent | gpgtar: Add dummy option --tar (diff) | |
download | gnupg-33fd55ca6f3efc50c260469179788e9f725ddc58.tar.gz gnupg-33fd55ca6f3efc50c260469179788e9f725ddc58.zip |
common: Strip trailing CR,LF from w32_strerror.
* common/stringhelp.c (w32_strerror): Strip trailing CR,LF.
* common/iobuf.c (iobuf_get_filelength): Use -1 and not 0 for the
arg to w32_strerror.
--
This is in particular annoying since we started to use a string
argument sanitizer in the logging code. Before that we just add an
extra blank line.
The second patch corrects a never yet seen error message.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/stringhelp.c')
-rw-r--r-- | common/stringhelp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/stringhelp.c b/common/stringhelp.c index 3424048f9..d7bb6bc37 100644 --- a/common/stringhelp.c +++ b/common/stringhelp.c @@ -789,6 +789,12 @@ w32_strerror (int ec) FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), strerr, DIM (strerr)-1, NULL); + { + /* Strip the CR,LF - we want just the string. */ + size_t n = strlen (strerr); + if (n > 2 && strerr[n-2] == '\r' && strerr[n-1] == '\n' ) + strerr[n-2] = 0; + } #endif return strerr; } |