Fix OOB read in DNS resolver am: 43264bc365 am: c5ea7569a8 am: 2c2546b158 am: cf6b3ecd4d

Original change: https://googleplex-android-review.googlesource.com/c/platform/bionic/+/12329970

Change-Id: I0a108632f55b67081192710ce9dbf347d580e35d
diff --git a/libc/dns/resolv/res_send.c b/libc/dns/resolv/res_send.c
index a645a6b..fa81e6d 100644
--- a/libc/dns/resolv/res_send.c
+++ b/libc/dns/resolv/res_send.c
@@ -948,6 +948,8 @@
 			else
 				break;
 		}
+		// return size should never exceed container size
+		resplen = anssiz;
 	}
 	/*
 	 * If the calling applicating has bailed out of
@@ -960,7 +962,7 @@
 		DprintQ((statp->options & RES_DEBUG) ||
 			(statp->pfcode & RES_PRF_REPLY),
 			(stdout, ";; old answer (unexpected):\n"),
-			ans, (resplen > anssiz) ? anssiz: resplen);
+			ans, resplen);
 		goto read_len;
 	}