com php-src: Fix bug #71459 - Integer overflow in iptcembed(): ext/standard/iptc.c

From: Date: Wed, 27 Jan 2016 01:26:52 +0000
Subject: com php-src: Fix bug #71459 - Integer overflow in iptcembed(): ext/standard/iptc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90861@lists.php.net to get a copy of this message
Commit: 54c210d2ea9b8539edcde1888b1104b96b38e886 Author: Stanislav Malyshev <stas@php.net> Tue, 26 Jan 2016 17:26:52 -0800 Parents: 6297a117d77fa3a0df2e21ca926a92c231819cd5 Branches: PHP-5.5 PHP-5.5.32 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=54c210d2ea9b8539edcde1888b1104b96b38e886 Log: Fix bug #71459 - Integer overflow in iptcembed() Bugs: https://bugs.php.net/71459 Changed paths: M ext/standard/iptc.c Diff: diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c index 05d778b..6f8aa5d 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -195,6 +195,11 @@ PHP_FUNCTION(iptcembed) RETURN_FALSE; } + if ((size_t)iptcdata_len >= SIZE_MAX - sizeof(psheader) - 1025) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "IPTC data too large"); + RETURN_FALSE; + } + if ((fp = VCWD_FOPEN(jpeg_file, "rb")) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open %s", jpeg_file); RETURN_FALSE; @@ -203,7 +208,7 @@ PHP_FUNCTION(iptcembed) if (spool < 2) { fstat(fileno(fp), &sb); - poi = spoolbuf = safe_emalloc(1, iptcdata_len + sizeof(psheader) + sb.st_size + 1024, 1); + poi = spoolbuf = safe_emalloc(1, (size_t)iptcdata_len + sizeof(psheader) + 1024 + 1, sb.st_size); memset(poi, 0, iptcdata_len + sizeof(psheader) + sb.st_size + 1024 + 1); }

« previous php.cvs (#90861) next »