Browse Source

* Port [3143] to 1.2.13
* Fix a possible memory leak with DNS. (fixes #296)


svn: 3144

Bryan Drewery 19 years ago
parent
commit
d9d2df7a59
3 changed files with 11 additions and 5 deletions
  1. 1 0
      doc/UPDATES
  2. 3 5
      src/adns.c
  3. 7 0
      src/botnet.c

+ 1 - 0
doc/UPDATES

@@ -10,6 +10,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fix ./binary -C not signalling the correct process under some situations. (fixes #315)
 * Fix ./binary -C not signalling the correct process under some situations. (fixes #315)
 * Fix security hole in all shell cmds. (fixes #321)
 * Fix security hole in all shell cmds. (fixes #321)
 * Make ./binary -E default to displaying every error. (fixes #322)
 * Make ./binary -E default to displaying every error. (fixes #322)
+* Fix a possible memory leak with DNS. (fixes #296)
 
 
 1.2.12 - http://wraith.shatow.net/milestone/1.2.12
 1.2.12 - http://wraith.shatow.net/milestone/1.2.12
 * Clearing a variable via 'set var -' now resets that variable to default settings. (implements #111)
 * Clearing a variable via 'set var -' now resets that variable to default settings. (implements #111)

+ 3 - 5
src/adns.c

@@ -233,8 +233,7 @@ static dns_query_t *alloc_query(void *client_data, dns_callback_t callback, cons
 {
 {
 	dns_query_t *q = (dns_query_t *) my_calloc(1, sizeof(*q));
 	dns_query_t *q = (dns_query_t *) my_calloc(1, sizeof(*q));
 
 
-	q->id = query_id;
-	query_id++;
+	q->id = query_id++;
 	q->query = strdup(query);
 	q->query = strdup(query);
 	q->answers = 0;
 	q->answers = 0;
 	q->callback = callback;
 	q->callback = callback;
@@ -425,7 +424,7 @@ int egg_dns_lookup(const char *host, int timeout, dns_callback_t callback, void
 
 
 	/* check if the query was already made */
 	/* check if the query was already made */
         if (find_query(host))
         if (find_query(host))
-          return(-1);
+          return(-2);
 
 
 	/* Allocate our query struct. */
 	/* Allocate our query struct. */
         q = alloc_query(client_data, callback, host);
         q = alloc_query(client_data, callback, host);
@@ -754,9 +753,8 @@ static int reverse_ip(const char *host, char *reverse)
 
 
 int egg_dns_cancel(int id, int issue_callback)
 int egg_dns_cancel(int id, int issue_callback)
 {
 {
-	dns_query_t *q, *prev;
+	dns_query_t *q, *prev = NULL;
 
 
-	prev = NULL;
 	for (q = query_head; q; q = q->next) {
 	for (q = query_head; q; q = q->next) {
 		if (q->id == id) break;
 		if (q->id == id) break;
 		prev = q;
 		prev = q;

+ 7 - 0
src/botnet.c

@@ -1002,8 +1002,15 @@ int botlink(char *linker, int idx, char *nick)
       dcc[i].bot = 1;
       dcc[i].bot = 1;
 
 
       int dns_id = egg_dns_lookup(bi->address, 20, botlink_dns_callback, (void *) i);
       int dns_id = egg_dns_lookup(bi->address, 20, botlink_dns_callback, (void *) i);
+       /* dns_id 
+        * -1 means it was cached and the callback already called
+        * -2 means it's already being looked up.. try again later .. */
       if (dns_id >= 0)
       if (dns_id >= 0)
         dcc[i].dns_id = dns_id;
         dcc[i].dns_id = dns_id;
+      else if (dns_id == -2) {
+        lostdcc(i);
+        return 0;
+      }
      
      
       return 1;
       return 1;
       /* wait for async reply */
       /* wait for async reply */