about summary refs log tree commit diff
path: root/resolv/resolv_context.h
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-07-01 00:53:05 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-07-03 21:01:42 +0200
commit3f853f22c87f0b671c0366eb290919719fa56c0e (patch)
tree23f8835838728d4be3efca524754c1a2f5bb0396 /resolv/resolv_context.h
parentf30a54b21b83f254533c59ca72ad17af5249c6be (diff)
downloadglibc-3f853f22c87f0b671c0366eb290919719fa56c0e.tar.gz
glibc-3f853f22c87f0b671c0366eb290919719fa56c0e.tar.xz
glibc-3f853f22c87f0b671c0366eb290919719fa56c0e.zip
resolv: Lift domain search list limits [BZ #19569] [BZ #21475]
This change uses the extended resolver state in struct resolv_conf to
store the search list.  If applications have not patched the _res
object directly, this extended search list will be used by the stub
resolver during name resolution.
Diffstat (limited to 'resolv/resolv_context.h')
-rw-r--r--resolv/resolv_context.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/resolv/resolv_context.h b/resolv/resolv_context.h
index ff9ef2c7fe..0f4d47d26d 100644
--- a/resolv/resolv_context.h
+++ b/resolv/resolv_context.h
@@ -93,6 +93,25 @@ struct resolv_context *__resolv_context_get_override (struct __res_state *)
   __attribute__ ((nonnull (1), warn_unused_result));
 libc_hidden_proto (__resolv_context_get_override)
 
+/* Return the search path entry at INDEX, or NULL if there are fewer
+   than INDEX entries.  */
+static __attribute__ ((nonnull (1), unused)) const char *
+__resolv_context_search_list (const struct resolv_context *ctx, size_t index)
+{
+  if (ctx->conf != NULL)
+    {
+      if (index < ctx->conf->search_list_size)
+        return ctx->conf->search_list[index];
+      else
+        return NULL;
+    }
+  /* Fallback.  ctx->resp->dnsrch is a NULL-terminated array.  */
+  for (size_t i = 0; ctx->resp->dnsrch[i] != NULL && i < MAXDNSRCH; ++i)
+    if (i == index)
+      return ctx->resp->dnsrch[i];
+  return NULL;
+}
+
 /* Called during thread shutdown to free the associated resolver
    context (mostly in response to cancellation, otherwise the
    __resolv_context_get/__resolv_context_put pairing will already have