summaryrefslogtreecommitdiff
path: root/ext/standard/dns.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2019-01-06 11:57:16 -0800
committerStanislav Malyshev <stas@php.net>2019-01-06 11:57:16 -0800
commitfe820fcba616a736b80e911cfc132388acd35ace (patch)
treed958a1c3d69c8089081a807f4fb8cdfa80007422 /ext/standard/dns.c
parent41af1e6781386cf540926ba9d1ff59a3402f8e01 (diff)
parent8d3dfabef459fe7815e8ea2fd68753fd17859d7b (diff)
downloadphp-git-fe820fcba616a736b80e911cfc132388acd35ace.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix #77369 - memcpy with negative length via crafted DNS response Fix more issues with encodilng length Fix #77270: imagecolormatch Out Of Bounds Write on Heap Fix bug #77380 (Global out of bounds read in xmlrpc base64 code) Fix bug #77371 (heap buffer overflow in mb regex functions - compile_string_node) Fix bug #77370 - check that we do not read past buffer end when parsing multibytes Fix #77269: Potential unsigned underflow in gdImageScale Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) Fix bug #77242 (heap out of bounds read in xmlrpc_decode()) Regenerate certs for openssl tests
Diffstat (limited to 'ext/standard/dns.c')
-rw-r--r--ext/standard/dns.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index fb21d6dd77..7d0442230a 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -456,6 +456,10 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
GETLONG(ttl, cp);
GETSHORT(dlen, cp);
CHECKCP(dlen);
+ if (dlen == 0) {
+ /* No data in the response - nothing to do */
+ return NULL;
+ }
if (type_to_fetch != T_ANY && type != type_to_fetch) {
cp += dlen;
return cp;
@@ -546,6 +550,9 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
CHECKCP(n);
add_assoc_stringl(subarray, "tag", (char*)cp, n);
cp += n;
+ if ( (size_t) dlen < ((size_t)n) + 2 ) {
+ return NULL;
+ }
n = dlen - n - 2;
CHECKCP(n);
add_assoc_stringl(subarray, "value", (char*)cp, n);