From cda87f750919e486751a005a1d42b8c97af6a94d Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 19 Oct 2002 09:52:00 +0000 Subject: [PATCH] Allow ifd start at offset other than 00000007h and provide testcase. #Now we can read images modified by Exifer. --- ext/exif/exif.c | 10 ++++++---- ext/exif/tests/005.phpt | 19 +++++++++++++++++++ ext/exif/tests/test5.jpg | Bin 0 -> 603 bytes 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 ext/exif/tests/005.phpt create mode 100644 ext/exif/tests/test5.jpg diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 8a8104d20e..810ed5dde8 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -3078,6 +3078,8 @@ static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, */ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t displacement TSRMLS_DC) { + unsigned exif_value_2a, offset_of_ifd; + /* 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; @@ -3089,16 +3091,16 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, } /* Check the next two values for correctness. */ - if (php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel) != 0x2a - || php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel) != 0x08 - ) { + exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); + offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); + if ( exif_value_2a != 0x2a || offset_of_ifd < 0x08) { exif_error_docref(NULL TSRMLS_CC, ImageInfo, E_WARNING, "invalid TIFF start (1)"); return; } ImageInfo->sections_found |= FOUND_IFD0; /* First directory starts at offset 8. Offsets starts at 0. */ - exif_process_IFD_in_JPEG(ImageInfo, CharBuf+8, CharBuf, length/*-14*/, displacement, SECTION_IFD0 TSRMLS_CC); + exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, CharBuf, length/*-14*/, displacement, SECTION_IFD0 TSRMLS_CC); #ifdef EXIF_DEBUG exif_error_docref(NULL TSRMLS_CC, ImageInfo, E_NOTICE, "process TIFF in JPEG done"); diff --git a/ext/exif/tests/005.phpt b/ext/exif/tests/005.phpt new file mode 100644 index 0000000000..d3c50c3815 --- /dev/null +++ b/ext/exif/tests/005.phpt @@ -0,0 +1,19 @@ +--TEST-- +Check for exif_read_data, unusual IFD start +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(2) { + ["ImageDescription"]=> + string(11) "Ifd00000009" + ["DateTime"]=> + string(19) "2002:10:18 20:06:00" +} \ No newline at end of file diff --git a/ext/exif/tests/test5.jpg b/ext/exif/tests/test5.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d03cac18a30928a9da73aa9aefd7bc38e2b743f8 GIT binary patch literal 603 zcmex=v&21X`Eh6EsF_ zkeiEJP?VpChhJ1eSXfk8SVE8o44@Q*gHAH?a&z}sZmE&&~} qSUklw)T|`+5!?y5U7(I|!v9+gJj`G_1sUuazJ^RcwNhpI|C<0o6qVxu literal 0 HcmV?d00001 -- 2.40.0