From 30dbdaa7504d7e7f1689efd075d8991ae8722e0b Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 6 Sep 2006 12:24:05 +0000 Subject: [PATCH] - Fixed small memory leak in resolver (~40 bytes when connecting to a server) - Made Unreal use the original name in case of a CNAME, instead of the forwarded name, reported by jerrcsnet (#0003054). - The "looking up your hostname" message was always sent, regardless of show-connect-info. --- Changes | 4 ++++ src/res.c | 21 +++++++++++---------- src/s_bsd.c | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index d1a6fbf50..970601448 100644 --- a/Changes +++ b/Changes @@ -1301,3 +1301,7 @@ - Fixes to SVSNICK: case-change no longer causes a collision, don't return the value from exit_client (which would be FLUSH_BUFFER), fix QUIT not being sent back on collision. - Fix for above so it doesn't -r the client. +- Fixed small memory leak in resolver (~40 bytes when connecting to a server) +- Made Unreal use the original name in case of a CNAME, instead of the forwarded name, + reported by jerrcsnet (#0003054). +- The "looking up your hostname" message was always sent, regardless of show-connect-info. diff --git a/src/res.c b/src/res.c index 1c7d5f754..191e874bd 100644 --- a/src/res.c +++ b/src/res.c @@ -207,7 +207,6 @@ char ipv4[4]; #else r->ipv6 = 0; #endif - r->name = strdup(name); unrealdns_addreqtolist(r); /* Execute it */ @@ -242,6 +241,7 @@ char ipv6 = r->ipv6; newr = MyMallocEx(sizeof(DNSReq)); newr->cptr = acptr; newr->ipv6 = ipv6; + newr->name = strdup(he->h_name); unrealdns_addreqtolist(newr); #ifndef INET6 @@ -276,10 +276,8 @@ int i; struct hostent *he2; u_int32_t ipv4_addr; - unrealdns_freeandremovereq(r); - if (!acptr) - return; + goto bad; if ((status != 0) || #ifdef INET6 @@ -290,7 +288,7 @@ u_int32_t ipv4_addr; { /* Failed: error code, or data length is not 4 (nor 16) */ proceed_normal_client_handshake(acptr, NULL); - return; + goto bad; } if (!ipv6) @@ -322,21 +320,24 @@ u_int32_t ipv4_addr; { /* Failed name <-> IP mapping */ proceed_normal_client_handshake(acptr, NULL); - return; + goto bad; } - if (!verify_hostname(he->h_name)) + if (!verify_hostname(r->name)) { /* Hostname is bad, don't cache and consider unresolved */ proceed_normal_client_handshake(acptr, NULL); - return; + goto bad; } /* Entry was found, verified, and can be added to cache */ - unrealdns_addtocache(he->h_name, &acptr->ip, sizeof(acptr->ip)); + unrealdns_addtocache(r->name, &acptr->ip, sizeof(acptr->ip)); - he2 = unreal_create_hostent(he->h_name, &acptr->ip); + he2 = unreal_create_hostent(r->name, &acptr->ip); proceed_normal_client_handshake(acptr, he2); + +bad: + unrealdns_freeandremovereq(r); } void unrealdns_cb_nametoip_link(void *arg, int status, struct hostent *he) diff --git a/src/s_bsd.c b/src/s_bsd.c index 2068c83c4..e45cc403c 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -1356,7 +1356,7 @@ struct hostent *he; if (!DONT_RESOLVE) { - if (!acptr->serv) + if (SHOWCONNECTINFO && !acptr->serv) sendto_one(acptr, "%s", REPORT_DO_DNS); dns_special_flag = 1; he = unrealdns_doclient(acptr);