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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-10-24 20:04:52 +02:00
parent 793fd8d876
commit 378719f25f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 4 additions and 2 deletions

View File

@ -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);
}