Skip to content

Commit

Permalink
Fix bug #78222 (heap-buffer-overflow on exif_scan_thumbnail)
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Jul 29, 2019
1 parent e944ae6 commit dea2989
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/exif/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3498,7 +3498,7 @@ static int exif_scan_thumbnail(image_info_type *ImageInfo)
size_t length=2, pos=0;
jpeg_sof_info sof_info;

if (!data) {
if (!data || ImageInfo->Thumbnail.size < 4) {
return FALSE; /* nothing to do here */
}
if (memcmp(data, "\xFF\xD8\xFF", 3)) {
Expand Down
Binary file added ext/exif/tests/bug78222.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions ext/exif/tests/bug78222.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Bug #78222 (heap-buffer-overflow on exif_scan_thumbnail)
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--FILE--
<?php
exif_read_data(__DIR__."/bug78222.jpg", 'THUMBNAIL', FALSE, TRUE);
?>
DONE
--EXPECTF--
DONE

0 comments on commit dea2989

Please sign in to comment.