helly           Sat Oct 19 06:24:04 2002 EDT

  Added files:                 (Branch: PHP_4_2_0)
    /php4/ext/exif/tests        005.phpt test5.jpg 

  Modified files:              
    /php4/ext/exif      exif.c 
  Log:
  MFH: Allow ifd start at offset other than 00000008h and provide testcase.
  
  
Index: php4/ext/exif/exif.c
diff -u php4/ext/exif/exif.c:1.52.2.12 php4/ext/exif/exif.c:1.52.2.13
--- php4/ext/exif/exif.c:1.52.2.12      Tue Sep  3 15:09:03 2002
+++ php4/ext/exif/exif.c        Sat Oct 19 06:24:03 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: exif.c,v 1.52.2.12 2002/09/03 19:09:03 helly Exp $ */
+/* $Id: exif.c,v 1.52.2.13 2002/10/19 10:24:03 helly Exp $ */
 
 /*     ToDos
  *
@@ -1606,6 +1606,8 @@
 */
 static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, 
unsigned int length)
 {
+       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;
@@ -1617,14 +1619,15 @@
        }
 
        /* 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) {
                php_error(E_WARNING, "Invalid TIFF start (1)");
                return;
        }
 
        /* First directory starts at offset 8. Offsets starts at 0. */
-       exif_process_IFD_in_JPEG(ImageInfo, CharBuf+8, CharBuf, length/*-14*/, 
SECTION_IFD0);
+       exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, CharBuf, 
+length/*-14*/, SECTION_IFD0);
 
 #ifdef EXIF_DEBUG
        php_error(E_NOTICE,"exif_process_TIFF_in_JPEG, done");

Index: php4/ext/exif/tests/005.phpt
+++ php4/ext/exif/tests/005.phpt
--TEST--
Check for exif_read_data, unusual IFD start
--SKIPIF--
<?php if (!extension_loaded("exif")) print "skip";?>
--FILE--
<?php
/*
  test5.jpg is a 1*1 image that contain an Exif section with ifd start at 00000009h
*/
$image  = exif_read_data('./ext/exif/tests/test5.jpg','',true,false);
var_dump($image['IFD0']);
?>
--EXPECT--
array(2) {
  ["ImageDescription"]=>
  string(11) "Ifd00000009"
  ["DateTime"]=>
  string(19) "2002:10:18 20:06:00"
}


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to