1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-07 17:33:02 +01:00

common: Fix memory leak.

* common/simple-pwquery.c (agent_open): Free socket path.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-06-30 17:23:48 +02:00
parent 29beea6462
commit 9037c23979

View File

@ -340,6 +340,7 @@ agent_open (int *rfd)
if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr
|| (p-infostr)+1 >= sizeof client_addr.sun_path ) || (p-infostr)+1 >= sizeof client_addr.sun_path )
{ {
spwq_free (infostr);
return SPWQ_NO_AGENT; return SPWQ_NO_AGENT;
} }
*p++ = 0; *p++ = 0;
@ -357,12 +358,14 @@ agent_open (int *rfd)
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error ("can't create socket: %s\n", strerror(errno) ); log_error ("can't create socket: %s\n", strerror(errno) );
#endif #endif
spwq_free (infostr);
return SPWQ_SYS_ERROR; return SPWQ_SYS_ERROR;
} }
memset (&client_addr, 0, sizeof client_addr); memset (&client_addr, 0, sizeof client_addr);
client_addr.sun_family = AF_UNIX; client_addr.sun_family = AF_UNIX;
strcpy (client_addr.sun_path, infostr); strcpy (client_addr.sun_path, infostr);
spwq_free (infostr);
len = SUN_LEN (&client_addr); len = SUN_LEN (&client_addr);
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
@ -373,7 +376,8 @@ agent_open (int *rfd)
if (rc == -1) if (rc == -1)
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error ( _("can't connect to '%s': %s\n"), infostr, strerror (errno)); log_error (_("can't connect to '%s': %s\n"),
client_addr.sun_path, strerror (errno));
#endif #endif
close (fd ); close (fd );
return SPWQ_IO_ERROR; return SPWQ_IO_ERROR;