aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_send.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-07-19 07:55:27 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-07-19 07:56:21 +0200
commit7131727c6ba451e1c5bf075194c7adc9292906c4 (patch)
tree97631b5bb76c074351e9d4278b7eeb290835b152 /resolv/res_send.c
parent72a51ac647b2fc33a44434d3d125a844801609ae (diff)
downloadglibc-7131727c6ba451e1c5bf075194c7adc9292906c4.tar
glibc-7131727c6ba451e1c5bf075194c7adc9292906c4.tar.gz
glibc-7131727c6ba451e1c5bf075194c7adc9292906c4.tar.bz2
glibc-7131727c6ba451e1c5bf075194c7adc9292906c4.zip
resolv: Move res_queriesmatch to its own file and into libc
And reformat it to GNU style. The treatment of this function matches res_nameinquery, for the reasons stated there. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'resolv/res_send.c')
-rw-r--r--resolv/res_send.c65
1 files changed, 6 insertions, 59 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c
index a5a33e6f3b..b502ef5132 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -248,61 +248,6 @@ mask_ad_bit (struct resolv_context *ctx, void *buf)
((HEADER *) buf)->ad = 0;
}
-/* int
- * res_queriesmatch(buf1, eom1, buf2, eom2)
- * is there a 1:1 mapping of (name,type,class)
- * in (buf1,eom1) and (buf2,eom2)?
- * returns:
- * -1 : format error
- * 0 : not a 1:1 mapping
- * >0 : is a 1:1 mapping
- * author:
- * paul vixie, 29may94
- */
-int
-res_queriesmatch(const u_char *buf1, const u_char *eom1,
- const u_char *buf2, const u_char *eom2)
-{
- if (buf1 + HFIXEDSZ > eom1 || buf2 + HFIXEDSZ > eom2)
- return (-1);
-
- /*
- * Only header section present in replies to
- * dynamic update packets.
- */
- if ((((HEADER *)buf1)->opcode == ns_o_update) &&
- (((HEADER *)buf2)->opcode == ns_o_update))
- return (1);
-
- /* Note that we initially do not convert QDCOUNT to the host byte
- order. We can compare it with the second buffer's QDCOUNT
- value without doing this. */
- int qdcount = ((HEADER*)buf1)->qdcount;
- if (qdcount != ((HEADER*)buf2)->qdcount)
- return (0);
-
- qdcount = htons (qdcount);
- const u_char *cp = buf1 + HFIXEDSZ;
-
- while (qdcount-- > 0) {
- char tname[MAXDNAME+1];
- int n, ttype, tclass;
-
- n = __libc_dn_expand (buf1, eom1, cp, tname, sizeof tname);
- if (n < 0)
- return (-1);
- cp += n;
- if (cp + 2 * INT16SZ > eom1)
- return (-1);
- NS_GET16(ttype, cp);
- NS_GET16(tclass, cp);
- if (!__libc_res_nameinquery (tname, ttype, tclass, buf2, eom2))
- return (0);
- }
- return (1);
-}
-libresolv_hidden_def (res_queriesmatch)
-
int
__res_context_send (struct resolv_context *ctx,
const unsigned char *buf, int buflen,
@@ -1239,13 +1184,15 @@ send_dg(res_state statp,
int matching_query = 0; /* Default to no matching query. */
if (!recvresp1
&& anhp->id == hp->id
- && res_queriesmatch (buf, buf + buflen,
- *thisansp, *thisansp + *thisanssizp))
+ && __libc_res_queriesmatch (buf, buf + buflen,
+ *thisansp,
+ *thisansp + *thisanssizp))
matching_query = 1;
if (!recvresp2
&& anhp->id == hp2->id
- && res_queriesmatch (buf2, buf2 + buflen2,
- *thisansp, *thisansp + *thisanssizp))
+ && __libc_res_queriesmatch (buf2, buf2 + buflen2,
+ *thisansp,
+ *thisansp + *thisanssizp))
matching_query = 2;
if (matching_query == 0)
/* Spurious UDP packet. Drop it and continue