aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2006-08-07 08:38:52 +0000
committerMatthias Andree <matthias.andree@gmx.de>2006-08-07 08:38:52 +0000
commitc37b5d80dcbc0b30427ac7671b9eccd8856b1579 (patch)
treefce7689e312b4747523da39ab5975dc0d90b6bb0 /socket.c
parent00428859b66df7161ee4a0d3f55afaa03aa7a2c3 (diff)
downloadfetchmail-c37b5d80dcbc0b30427ac7671b9eccd8856b1579.tar.gz
fetchmail-c37b5d80dcbc0b30427ac7671b9eccd8856b1579.tar.bz2
fetchmail-c37b5d80dcbc0b30427ac7671b9eccd8856b1579.zip
Freeaddrinfo() fix for Uli Zappe's bug.
This might fix Debian Bug#294547 and Bug#377135. svn path=/branches/BRANCH_6-3/; revision=4880
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/socket.c b/socket.c
index ee9600fd..080f1888 100644
--- a/socket.c
+++ b/socket.c
@@ -264,19 +264,20 @@ int UnixOpen(const char *path)
}
int SockOpen(const char *host, const char *service,
- const char *plugin)
+ const char *plugin, struct addrinfo **ai0)
{
- struct addrinfo *ai, *ai0, req;
+ struct addrinfo *ai, req;
int i, acterr = 0;
#ifdef HAVE_SOCKETPAIR
if (plugin)
return handle_plugin(host,service,plugin);
#endif /* HAVE_SOCKETPAIR */
+
memset(&req, 0, sizeof(struct addrinfo));
req.ai_socktype = SOCK_STREAM;
- i = getaddrinfo(host, service, &req, &ai0);
+ i = getaddrinfo(host, service, &req, ai0);
if (i) {
report(stderr, GT_("getaddrinfo(\"%s\",\"%s\") error: %s\n"),
host, service, gai_strerror(i));
@@ -286,7 +287,7 @@ int SockOpen(const char *host, const char *service,
}
i = -1;
- for (ai = ai0; ai; ai = ai->ai_next) {
+ for (ai = *ai0; ai; ai = ai->ai_next) {
char buf[80],pb[80];
int gnie;
@@ -339,7 +340,8 @@ int SockOpen(const char *host, const char *service,
break;
}
- freeaddrinfo(ai0);
+ freeaddrinfo(*ai0);
+ *ai0 = NULL;
if (i == -1)
errno = acterr;