hesiod/hesiod-3.1.0-dnsparse.patch

50 lines
1.1 KiB
Diff

If the response is larger than 1024 bytes, go ahead and retry.
--- hesiod-3.1.0/hesiod.c 2006-03-30 13:22:57.000000000 -0500
+++ hesiod-3.1.0/hesiod.c 2006-03-30 13:28:16.000000000 -0500
@@ -327,7 +327,8 @@
*/
static char **get_txt_records(struct hesiod_p *ctx, const char *name)
{
- unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP];
+ unsigned char qbuf[PACKETSZ], *abuf;
+ char **tmp;
- int n;
+ int n, i, len;
/* Make sure the resolver is initialized. */
@@ -343,14 +344,30 @@
}
/* Send the query. */
- n = res_send(qbuf, n, abuf, MAX_HESRESP);
- if (n < 0)
+ abuf = NULL;
+ len = 1024;
+ i = n;
+ do
+ {
+ abuf = realloc(abuf, len);
+ n = res_send(qbuf, i, abuf, len);
+ if (n < len)
+ {
+ break;
+ }
+ len = n + 1024;
+ } while(1);
+ if (n < sizeof(HEADER))
{
errno = ECONNREFUSED;
return NULL;
}
- return hesiod_parse_result(ctx, abuf, n);
+ tmp = hesiod_parse_result(ctx, abuf, n);
+
+ free(abuf);
+
+ return tmp;
}
char **hesiod_parse_result(void *ctx, const unsigned char *abuf, int alen)