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