diff options
author | Werner Koch <[email protected]> | 2017-11-22 19:54:07 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-11-22 19:54:47 +0000 |
commit | ea28ea18f3ee6c9f5e69986f39848398b58e242e (patch) | |
tree | e9fa094bad034fb7459c9480f82e14b410c2d60a | |
parent | scd: Enable card removal check after select_application. (diff) | |
download | gnupg-ea28ea18f3ee6c9f5e69986f39848398b58e242e.tar.gz gnupg-ea28ea18f3ee6c9f5e69986f39848398b58e242e.zip |
gpg: Fix memory leaking for long inputs via --command-fd.
* g10/cpr.c (do_get_from_fd): Free the old buffer.
--
If the received input is longer than 200 characters we used to leak
the previous allocated buffer.
GnuPG-bug-id: 3528
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | g10/cpr.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -425,11 +425,17 @@ do_get_from_fd ( const char *keyword, int hidden, int getbool ) { if (i >= len-1 ) { + /* On the first iteration allocate a new buffer. If that + * buffer is too short at further iterations do a poor man's + * realloc. */ char *save = string; len += 100; string = hidden? xmalloc_secure ( len ) : xmalloc ( len ); if (save) - memcpy (string, save, i ); + { + memcpy (string, save, i); + xfree (save); + } else i = 0; } |