Skip to content

Commit

Permalink
Fixed bug #79282
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Mar 16, 2020
1 parent 63f6608 commit 41f66e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/exif/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,11 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
{
unsigned exif_value_2a, offset_of_ifd;

if (length < 2) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
return;
}

/* set the thumbnail stuff to nothing so we can test to see if they get set up */
if (memcmp(CharBuf, "II", 2) == 0) {
ImageInfo->motorola_intel = 0;
Expand Down Expand Up @@ -3844,7 +3849,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
return FALSE;
}

sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
Data = ImageInfo->file.list[sn].data;

/* Store first two pre-read bytes. */
Expand Down
15 changes: 15 additions & 0 deletions ext/exif/tests/bug79282.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Bug #79282: Use-of-uninitialized-value in exif
--FILE--
<?php

var_dump(exif_read_data('data://image/jpeg;base64,/9jhAAlFeGlmAAAg'));

?>
--EXPECTF--
Warning: exif_read_data(): Invalid TIFF alignment marker in %s on line %d

Warning: exif_read_data(): File structure corrupted in %s on line %d

Warning: exif_read_data(): Invalid JPEG file in %s on line %d
bool(false)

0 comments on commit 41f66e2

Please sign in to comment.