8597553f96
- Support an arbitrary number of search domains (#168253) - Detect and apply /etc/resolv.conf changes in libresolv (#1374239) - CVE-2015-5180: DNS stub resolver crash with crafted record type (#1251403)
198 lines
4.9 KiB
Diff
198 lines
4.9 KiB
Diff
commit 037751179905c7d6d624f287029237565465fa9a
|
||
Author: Florian Weimer <fweimer@redhat.com>
|
||
Date: Fri Jun 30 11:31:54 2017 +0200
|
||
|
||
resolv: Move res_query, res_search res_querydomain, hostalias
|
||
|
||
From res_data.c to query.c
|
||
|
||
diff --git a/resolv/res_data.c b/resolv/res_data.c
|
||
index b790b4b725bc9edd..5e7688c706bf8e99 100644
|
||
--- a/resolv/res_data.c
|
||
+++ b/resolv/res_data.c
|
||
@@ -15,35 +15,7 @@
|
||
* SOFTWARE.
|
||
*/
|
||
|
||
-#include <sys/types.h>
|
||
-#include <sys/param.h>
|
||
-#include <sys/socket.h>
|
||
-#include <sys/time.h>
|
||
-
|
||
-#include <netinet/in.h>
|
||
-#include <arpa/inet.h>
|
||
-#include <arpa/nameser.h>
|
||
-
|
||
-#include <ctype.h>
|
||
-#include <netdb.h>
|
||
#include <resolv.h>
|
||
-#include <stdio.h>
|
||
-#include <stdlib.h>
|
||
-#include <string.h>
|
||
-#include <unistd.h>
|
||
-
|
||
-int
|
||
-res_query(const char *name, /* domain name */
|
||
- int class, int type, /* class and type of query */
|
||
- u_char *answer, /* buffer to put answer */
|
||
- int anslen) /* size of answer buffer */
|
||
-{
|
||
- if (__res_maybe_init (&_res, 1) == -1) {
|
||
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||
- return (-1);
|
||
- }
|
||
- return (res_nquery(&_res, name, class, type, answer, anslen));
|
||
-}
|
||
|
||
void
|
||
res_close(void) {
|
||
@@ -60,55 +32,3 @@ res_close(void) {
|
||
did it and it would be done implicitly on shutdown. */
|
||
__res_iclose(&_res, false);
|
||
}
|
||
-
|
||
-int
|
||
-res_search(const char *name, /* domain name */
|
||
- int class, int type, /* class and type of query */
|
||
- u_char *answer, /* buffer to put answer */
|
||
- int anslen) /* size of answer */
|
||
-{
|
||
- if (__res_maybe_init (&_res, 1) == -1) {
|
||
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||
- return (-1);
|
||
- }
|
||
-
|
||
- return (res_nsearch(&_res, name, class, type, answer, anslen));
|
||
-}
|
||
-
|
||
-int
|
||
-res_querydomain(const char *name,
|
||
- const char *domain,
|
||
- int class, int type, /* class and type of query */
|
||
- u_char *answer, /* buffer to put answer */
|
||
- int anslen) /* size of answer */
|
||
-{
|
||
- if (__res_maybe_init (&_res, 1) == -1) {
|
||
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||
- return (-1);
|
||
- }
|
||
-
|
||
- return (res_nquerydomain(&_res, name, domain,
|
||
- class, type,
|
||
- answer, anslen));
|
||
-}
|
||
-
|
||
-const char *
|
||
-hostalias(const char *name) {
|
||
- static char abuf[MAXDNAME];
|
||
-
|
||
- return (res_hostalias(&_res, name, abuf, sizeof abuf));
|
||
-}
|
||
-libresolv_hidden_def (hostalias)
|
||
-
|
||
-
|
||
-
|
||
-#include <shlib-compat.h>
|
||
-
|
||
-#if SHLIB_COMPAT(libresolv, GLIBC_2_0, GLIBC_2_2)
|
||
-# undef res_query
|
||
-# undef res_querydomain
|
||
-# undef res_search
|
||
-weak_alias (__res_query, res_query);
|
||
-weak_alias (__res_querydomain, res_querydomain);
|
||
-weak_alias (__res_search, res_search);
|
||
-#endif
|
||
diff --git a/resolv/res_query.c b/resolv/res_query.c
|
||
index 0ca3a650282ec7f0..5312c8e729c39516 100644
|
||
--- a/resolv/res_query.c
|
||
+++ b/resolv/res_query.c
|
||
@@ -78,7 +78,7 @@
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
-#include <resolv/resolv-internal.h>
|
||
+#include <shlib-compat.h>
|
||
|
||
/* Options. Leave them on. */
|
||
/* #undef DEBUG */
|
||
@@ -319,6 +319,18 @@ res_nquery(res_state statp,
|
||
}
|
||
libresolv_hidden_def (res_nquery)
|
||
|
||
+int
|
||
+res_query (const char *name, int class, int type,
|
||
+ unsigned char *answer, int anslen)
|
||
+{
|
||
+ if (__res_maybe_init (&_res, 1) == -1)
|
||
+ {
|
||
+ RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
|
||
+ return -1;
|
||
+ }
|
||
+ return res_nquery (&_res, name, class, type, answer, anslen);
|
||
+}
|
||
+
|
||
/*
|
||
* Formulate a normal query, send, and retrieve answer in supplied buffer.
|
||
* Return the size of the response on success, -1 on error.
|
||
@@ -545,6 +557,19 @@ res_nsearch(res_state statp,
|
||
}
|
||
libresolv_hidden_def (res_nsearch)
|
||
|
||
+int
|
||
+res_search (const char *name, int class, int type,
|
||
+ unsigned char *answer, int anslen)
|
||
+{
|
||
+ if (__res_maybe_init (&_res, 1) == -1)
|
||
+ {
|
||
+ RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
|
||
+ return -1;
|
||
+ }
|
||
+
|
||
+ return res_nsearch (&_res, name, class, type, answer, anslen);
|
||
+}
|
||
+
|
||
/*
|
||
* Perform a call on res_query on the concatenation of name and domain.
|
||
*/
|
||
@@ -610,6 +635,19 @@ res_nquerydomain(res_state statp,
|
||
}
|
||
libresolv_hidden_def (res_nquerydomain)
|
||
|
||
+int
|
||
+res_querydomain (const char *name, const char *domain, int class, int type,
|
||
+ unsigned char *answer, int anslen)
|
||
+{
|
||
+ if (__res_maybe_init (&_res, 1) == -1)
|
||
+ {
|
||
+ RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
|
||
+ return -1;
|
||
+ }
|
||
+
|
||
+ return res_nquerydomain (&_res, name, domain, class, type, answer, anslen);
|
||
+}
|
||
+
|
||
const char *
|
||
res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
|
||
char *file, *cp1, *cp2;
|
||
@@ -647,3 +685,20 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
|
||
return (NULL);
|
||
}
|
||
libresolv_hidden_def (res_hostalias)
|
||
+
|
||
+const char *
|
||
+hostalias (const char *name)
|
||
+{
|
||
+ static char abuf[MAXDNAME];
|
||
+ return res_hostalias (&_res, name, abuf, sizeof abuf);
|
||
+}
|
||
+libresolv_hidden_def (hostalias)
|
||
+
|
||
+#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_2)
|
||
+# undef res_query
|
||
+# undef res_querydomain
|
||
+# undef res_search
|
||
+weak_alias (__res_query, res_query);
|
||
+weak_alias (__res_querydomain, res_querydomain);
|
||
+weak_alias (__res_search, res_search);
|
||
+#endif
|