[or-cvs] r7061: Patch from Adam Langley. * I meant getaddrinfo_a, not getadd (in tor/trunk: . src/or)
nickm at seul.org
nickm at seul.org
Mon Aug 14 21:44:45 UTC 2006
Author: nickm
Date: 2006-08-14 17:44:45 -0400 (Mon, 14 Aug 2006)
New Revision: 7061
Modified:
tor/trunk/
tor/trunk/src/or/eventdns.c
Log:
r7386 at Kushana: nickm | 2006-08-14 17:43:44 -0400
Patch from Adam Langley.
* I meant getaddrinfo_a, not getaddrinfo_r - fixed
* Added more checks to the parsing code.
* It seems you switched an alloca to a malloc, but didn't add any frees
Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
- 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7054
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:7383
+ 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7386
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:7383
Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c 2006-08-14 21:44:39 UTC (rev 7060)
+++ tor/trunk/src/or/eventdns.c 2006-08-14 21:44:45 UTC (rev 7061)
@@ -3,7 +3,7 @@
/* The original version of this module was written by Adam Langley; for
* a history of modifications, check out the subversion logs.
*
- * When editiing this module, try to keep it re-mergeable by Adam. Don't
+ * When editing this module, try to keep it re-mergeable by Adam. Don't
* reformat the whitespace, add Tor dependencies, or so on.
*
* TODO:
@@ -39,12 +39,10 @@
* Async DNS lookups are really a whole lot harder than they should be,
* mostly stemming from the fact that the libc resolver has never been
* very good at them. Before you use this library you should see if libc
- * can do the job for you with the modern async call getaddrinfo_r
- * (Google for it). Otherwise, please continue.
+ * can do the job for you with the modern async call getaddrinfo_a
+ * (see http://www.imperialviolet.org/page25.html#e498). Otherwise,
+ * please continue.
*
- * [I googled for getaddrinfo_r and got only two hits, one of which was this
- * code. Did you mean something different? -NM]
- *
* This code is based on libevent and you must call event_init before
* any of the APIs in this file. You must also seed the OpenSSL random
* source if you are using OpenSSL for ids (see below).
@@ -783,6 +781,7 @@
// packet. The name stops after a pointer like that.
#define SKIP_NAME \
for(;;) { \
+ if (j >= length) return;
u8 label_len; \
GET8(label_len); \
if (!label_len) break; \
@@ -800,6 +799,7 @@
// <label:name><u16:type><u16:class>
SKIP_NAME;
j += 4;
+ if (j >= length) return;
}
// now we have the answer section which looks like
@@ -1054,9 +1054,13 @@
labels = (u8 *) malloc(name_len + 2);
if (!labels) return -1;
labels_len = dnsname_to_labels(labels, name, name_len);
- if (labels_len < 0) return labels_len;
+ if (labels_len < 0) {
+ free(labels);
+ return labels_len;
+ }
memcpy(buf + j, labels, labels_len);
j += labels_len;
+ free(labels);
APPEND16(type);
APPEND16(class);
More information about the tor-commits
mailing list