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