Merge the 2021-02-05 SPL branch from AOSP-Partner
* security-aosp-pi-release:
Fix OOB read in DNS resolver
Change-Id: I8e96083695807d17a95edef2b69b02d5135cfadb
diff --git a/libc/dns/resolv/res_send.c b/libc/dns/resolv/res_send.c
index 18bb752..81b42a6 100644
--- a/libc/dns/resolv/res_send.c
+++ b/libc/dns/resolv/res_send.c
@@ -950,6 +950,8 @@
else
break;
}
+ // return size should never exceed container size
+ resplen = anssiz;
}
/*
* If the calling applicating has bailed out of
@@ -962,7 +964,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;
}