com php-src: Fixed bug #77564: Memory leak in exif_process_ IFD_TAG: NEWS ext/exif/exif.c ext/exif/tests/bug7 7564/bug77564.jpg ext/exif/tests/bug7
7564/bug77564.phpt

From: Date: Tue, 12 Feb 2019 08:28:33 +0000
Subject: com php-src: Fixed bug #77564: Memory leak in exif_process_ IFD_TAG: NEWS ext/exif/exif.c ext/exif/tests/bug7 7564/bug77564.jpg ext/exif/tests/bug7
7564/bug77564.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104571@lists.php.net to get a copy of this message
Commit: c4294440ffc4a59a1298292b76072e6759034a68 Author: Ben Ramsey <ben@benramsey.com> Sun, 10 Feb 2019 12:25:19 -0600 Committer: Nikita Popov <nikita.ppv@gmail.com> Tue, 12 Feb 2019 09:28:33 +0100 Parents: 9222702633c63254b08466b322266b647ac3e905 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c4294440ffc4a59a1298292b76072e6759034a68 Log: Fixed bug #77564: Memory leak in exif_process_IFD_TAG The memory leak occurs when more than one UserComment tag is present in the EXIF data. It's still considered corrupt EXIF data, but this ensures the memory is freed before trying to set to already allocated memory. Bugs: https://bugs.php.net/77564 Changed paths: M NEWS M ext/exif/exif.c A ext/exif/tests/bug77564/bug77564.jpg A ext/exif/tests/bug77564/bug77564.phpt Diff: diff --git a/NEWS b/NEWS index fa5200c..533b04e 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ PHP NEWS . Fixed bug #77589 (Core dump using parse_ini_string with numeric sections). (Laruence) +- Exif: + . Fixed bug #77564 (Memory leak in exif_process_IFD_TAG). (Ben Ramsey) + - PDO_OCI: . Support Oracle Database tracing attributes ACTION, MODULE, CLIENT_INFO, and CLIENT_IDENTIFIER. (Cameron Porter) diff --git a/ext/exif/exif.c b/ext/exif/exif.c index be02c9d..9c20219 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -3405,6 +3405,10 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha break; case TAG_USERCOMMENT: + EFREE_IF(ImageInfo->UserComment); + ImageInfo->UserComment = NULL; + EFREE_IF(ImageInfo->UserCommentEncoding); + ImageInfo->UserCommentEncoding = NULL; ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(ImageInfo->UserCommentEncoding), value_ptr, byte_count); break; diff --git a/ext/exif/tests/bug77564/bug77564.jpg b/ext/exif/tests/bug77564/bug77564.jpg new file mode 100644 index 0000000..868fffd Binary files /dev/null and b/ext/exif/tests/bug77564/bug77564.jpg differ diff --git a/ext/exif/tests/bug77564/bug77564.phpt b/ext/exif/tests/bug77564/bug77564.phpt new file mode 100644 index 0000000..2f72b3c --- /dev/null +++ b/ext/exif/tests/bug77564/bug77564.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug 77564 (Memory leak in exif_process_IFD_TAG) +--SKIPIF-- +<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?> +--FILE-- +<?php +var_dump(exif_read_data(dirname(__FILE__) . '/bug77564.jpg')); +?> +DONE +--EXPECTF-- + +Warning: exif_read_data(bug77564.jpg): Illegal IFD offset in %sbug77564.php on line %d + +Warning: exif_read_data(bug77564.jpg): File structure corrupted in %sbug77564.php on line %d + +Warning: exif_read_data(bug77564.jpg): Invalid JPEG file in %sbug77564.php on line %d +bool(false) +DONE

« previous php.cvs (#104571) next »