edfbb2
Partial backport of:
edfbb2
edfbb2
commit 333221862ecbebde60dd16e7ca17d26444e62f50
edfbb2
Author: Florian Weimer <fweimer@redhat.com>
edfbb2
Date:   Mon Apr 8 11:19:38 2019 +0200
edfbb2
edfbb2
    resolv: Remove RES_INSECURE1, RES_INSECURE2
edfbb2
    
edfbb2
    Always perform the associated security checks.
edfbb2
edfbb2
The constants and their debug output handling are preserve in this
edfbb2
backport.
edfbb2
edfbb2
diff --git a/resolv/res_send.c b/resolv/res_send.c
edfbb2
index 705ecb7189d215c2..c9b02cca130bc20d 100644
edfbb2
--- a/resolv/res_send.c
edfbb2
+++ b/resolv/res_send.c
edfbb2
@@ -1324,31 +1324,25 @@ send_dg(res_state statp,
edfbb2
 			 */
edfbb2
 			goto wait;
edfbb2
 		}
edfbb2
-		if (!(statp->options & RES_INSECURE1) &&
edfbb2
-		    !res_ourserver_p(statp, &from)) {
edfbb2
-			/*
edfbb2
-			 * response from wrong server? ignore it.
edfbb2
-			 * XXX - potential security hazard could
edfbb2
-			 *	 be detected here.
edfbb2
-			 */
edfbb2
-			goto wait;
edfbb2
-		}
edfbb2
-		if (!(statp->options & RES_INSECURE2)
edfbb2
-		    && (recvresp1 || !res_queriesmatch(buf, buf + buflen,
edfbb2
+
edfbb2
+		/* Paranoia check.  Due to the connected UDP socket,
edfbb2
+		   the kernel has already filtered invalid addresses
edfbb2
+		   for us.  */
edfbb2
+		if (!res_ourserver_p(statp, &from))
edfbb2
+		  goto wait;
edfbb2
+
edfbb2
+		/* Check for the correct header layout and a matching
edfbb2
+		   question.  */
edfbb2
+		if ((recvresp1 || !res_queriesmatch(buf, buf + buflen,
edfbb2
 						       *thisansp,
edfbb2
 						       *thisansp
edfbb2
 						       + *thisanssizp))
edfbb2
 		    && (recvresp2 || !res_queriesmatch(buf2, buf2 + buflen2,
edfbb2
 						       *thisansp,
edfbb2
 						       *thisansp
edfbb2
-						       + *thisanssizp))) {
edfbb2
-			/*
edfbb2
-			 * response contains wrong query? ignore it.
edfbb2
-			 * XXX - potential security hazard could
edfbb2
-			 *	 be detected here.
edfbb2
-			 */
edfbb2
-			goto wait;
edfbb2
-		}
edfbb2
+						       + *thisanssizp)))
edfbb2
+		  goto wait;
edfbb2
+
edfbb2
 		if (anhp->rcode == SERVFAIL ||
edfbb2
 		    anhp->rcode == NOTIMP ||
edfbb2
 		    anhp->rcode == REFUSED) {