com php-src: Fix bug #71459 - Integer overflow in iptcembed(): ext/standard/iptc.c
| From: | Stanislav Malyshev | Date: | Wed, 27 Jan 2016 01:30:50 +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-90879@lists.php.net to get a copy of this message | ||
Commit: f379142d66885cae8b13db884ff76fe398421884
Author: Stanislav Malyshev <stas@php.net> Tue, 26 Jan 2016 17:26:52 -0800
Parents: 52e0c4081f8454e9086fc7d1bd1a338ac4e05868
Branches: PHP-7.0 PHP-7.0.3 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f379142d66885cae8b13db884ff76fe398421884
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 a354706..b10d844 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -196,6 +196,11 @@ PHP_FUNCTION(iptcembed)
RETURN_FALSE;
}
+ if (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, E_WARNING, "Unable to open %s", jpeg_file);
RETURN_FALSE;
@@ -204,7 +209,7 @@ PHP_FUNCTION(iptcembed)
if (spool < 2) {
zend_fstat(fileno(fp), &sb);
- spoolbuf = zend_string_alloc(iptcdata_len + sizeof(psheader) + sb.st_size + 1024, 0);
+ spoolbuf = zend_string_safe_alloc(1, iptcdata_len + sizeof(psheader) + 1024 + 1, sb.st_size, 0);
poi = (unsigned char*)ZSTR_VAL(spoolbuf);
memset(poi, 0, iptcdata_len + sizeof(psheader) + sb..st_size + 1024 + 1);
}