diff options
-rw-r--r-- | resolv/res_query.c | 8 | ||||
-rw-r--r-- | resolv/tst-resolv-qtypes.c | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c index 1b148a2a05..bd55453552 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -81,6 +81,7 @@ #include <string.h> #include <shlib-compat.h> #include <scratch_buffer.h> +#include <stdbool.h> #if PACKETSZ > 65536 #define MAXPACKET PACKETSZ @@ -116,6 +117,7 @@ __res_context_query (struct resolv_context *ctx, const char *name, UHEADER *hp = (UHEADER *) answer; UHEADER *hp2; int n; + bool retried = false; /* It requires 2 times QUERYSIZE for type == T_QUERY_A_AND_AAAA. */ struct scratch_buffer buf; @@ -182,13 +184,15 @@ __res_context_query (struct resolv_context *ctx, const char *name, nquery1 = n; } - if (__glibc_unlikely (n <= 0)) { + if (__glibc_unlikely (n <= 0) && !retried) { /* Retry just in case res_nmkquery failed because of too short buffer. Shouldn't happen. */ if (scratch_buffer_set_array_size (&buf, - T_QUERY_A_AND_AAAA ? 2 : 1, + (type == T_QUERY_A_AND_AAAA) + ? 2 : 1, MAXPACKET)) { query1 = buf.data; + retried = true; goto again; } } diff --git a/resolv/tst-resolv-qtypes.c b/resolv/tst-resolv-qtypes.c index 3fa566c7ea..973c4e15d3 100644 --- a/resolv/tst-resolv-qtypes.c +++ b/resolv/tst-resolv-qtypes.c @@ -154,8 +154,8 @@ test_function (const char *fname, } } - TEST_VERIFY (func (-1, buf, sizeof (buf) == -1)); - TEST_VERIFY (func (65536, buf, sizeof (buf) == -1)); + TEST_VERIFY (func (-1, buf, sizeof (buf)) == -1); + TEST_VERIFY (func (65536, buf, sizeof (buf)) == -1); } static int |