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,36 @@ } /* 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; + } + n = res_send(qbuf, i, abuf, len); + if (n < len) + { + break; + } + len = n + 1024; + } while(1); + if (n < (ssize_t) sizeof(HEADER)) { errno = ECONNREFUSED; + free(abuf); 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)