diff options
author | Werner Koch <[email protected]> | 2018-10-24 18:04:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-10-24 18:04:52 +0000 |
commit | 378719f25fe00d46393541f4a4f79e04484c3000 (patch) | |
tree | 02756cc4c4f3feba528c4819c38cb702a86477e2 /tools/gpg-connect-agent.c | |
parent | sm: Use the correct string in an error message. (diff) | |
download | gnupg-378719f25fe00d46393541f4a4f79e04484c3000.tar.gz gnupg-378719f25fe00d46393541f4a4f79e04484c3000.zip |
tools: Fix FILE memory leak in gpg-connect-agent.
* tools/gpg-connect-agent.c (do_open): dup the fileno and close the
stream.
GnuPG-bug-id: 4220
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/gpg-connect-agent.c')
-rw-r--r-- | tools/gpg-connect-agent.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index 00482a32e..7eb7ffa3a 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -983,7 +983,7 @@ do_open (char *line) name, mode, strerror (errno)); return; } - fd = fileno (fp); + fd = dup (fileno (fp)); if (fd >= 0 && fd < DIM (open_fd_table)) { open_fd_table[fd].inuse = 1; @@ -1030,8 +1030,10 @@ do_open (char *line) else { log_error ("can't put fd %d into table\n", fd); - close (fd); + if (fd != -1) + close (fd); /* Table was full. */ } + fclose (fp); } |