hesiod/hesiod-3.1.0-dnsparse.patch

57 lines
1.3 KiB
Diff
Raw Normal View History

2006-03-30 18:58:28 +00:00
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
2008-07-22 20:09:39 +00:00
@@ -327,8 +327,9 @@
2006-03-30 18:58:28 +00:00
*/
static char **get_txt_records(struct hesiod_p *ctx, const char *name)
{
- unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP];
2008-07-22 20:09:39 +00:00
- int n;
2006-03-30 18:58:28 +00:00
+ unsigned char qbuf[PACKETSZ], *abuf;
+ char **tmp;
+ int n, i, len;
/* Make sure the resolver is initialized. */
2008-07-22 20:09:39 +00:00
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
@@ -343,14 +344,36 @@
2006-03-30 18:58:28 +00:00
}
/* 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);
+ if (abuf == NULL)
+ {
+ n = -1;
+ break;
+ }
2006-03-30 18:58:28 +00:00
+ n = res_send(qbuf, i, abuf, len);
+ if (n < len)
+ {
+ break;
+ }
+ len = n + 1024;
+ } while(1);
+ if (n < (ssize_t) sizeof(HEADER))
2006-03-30 18:58:28 +00:00
{
errno = ECONNREFUSED;
+ free(abuf);
2006-03-30 18:58:28 +00:00
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)