diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2006-08-07 08:38:52 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2006-08-07 08:38:52 +0000 |
commit | c37b5d80dcbc0b30427ac7671b9eccd8856b1579 (patch) | |
tree | fce7689e312b4747523da39ab5975dc0d90b6bb0 /socket.c | |
parent | 00428859b66df7161ee4a0d3f55afaa03aa7a2c3 (diff) | |
download | fetchmail-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.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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; |