@@ -1374,10 +1374,10 @@ static char *exif_get_tagname_key(int tag_num, char *buf, size_t buf_size, tag_t
1374
1374
/* {{{ exif_char_dump
1375
1375
* Do not use! This is a debug function... */
1376
1376
#ifdef EXIF_DEBUG
1377
- static unsigned char * exif_char_dump (unsigned char * addr , int len , int offset )
1377
+ static char * exif_char_dump (char * addr , int len , int offset )
1378
1378
{
1379
- static unsigned char buf [4096 + 1 ];
1380
- static unsigned char tmp [20 ];
1379
+ static char buf [4096 + 1 ];
1380
+ static char tmp [20 ];
1381
1381
int c , i , p = 0 , n = 5 + 31 ;
1382
1382
1383
1383
p += slprintf (buf + p , sizeof (buf )- p , "\nDump Len: %08X (%d)" , len , len );
@@ -1387,7 +1387,7 @@ static unsigned char* exif_char_dump(unsigned char * addr, int len, int offset)
1387
1387
p += slprintf (buf + p , sizeof (buf )- p , "\n%08X: " , i + offset );
1388
1388
}
1389
1389
if (i < len ) {
1390
- c = * addr ++ ;
1390
+ c = * (( unsigned char * ) addr ++ ) ;
1391
1391
p += slprintf (buf + p , sizeof (buf )- p , "%02X " , c );
1392
1392
tmp [i %16 ] = c >=32 ? c : '.' ;
1393
1393
tmp [(i %16 )+ 1 ] = '\0' ;
@@ -1536,7 +1536,7 @@ static double php_ifd_get_double(char *data) {
1536
1536
}
1537
1537
1538
1538
#ifdef EXIF_DEBUG
1539
- char * exif_dump_data (int * dump_free , int format , int components , int length , int motorola_intel , char * value_ptr ) /* {{{ */
1539
+ char * exif_dump_data (int * dump_free , int format , int components , int motorola_intel , char * value_ptr ) /* {{{ */
1540
1540
{
1541
1541
char * dump ;
1542
1542
int len ;
@@ -1556,7 +1556,7 @@ char * exif_dump_data(int *dump_free, int format, int components, int length, in
1556
1556
}
1557
1557
* dump_free = 1 ;
1558
1558
if (components > 1 ) {
1559
- len = spprintf (& dump , 0 , "(%d,%d ) {" , components , length );
1559
+ len = spprintf (& dump , 0 , "(%d) {" , components );
1560
1560
} else {
1561
1561
len = spprintf (& dump , 0 , "{" );
1562
1562
}
@@ -1981,7 +1981,12 @@ typedef struct {
1981
1981
} image_info_type ;
1982
1982
/* }}} */
1983
1983
1984
+ // EXIF_DEBUG can produce lots of messages
1985
+ #ifndef EXIF_DEBUG
1984
1986
#define EXIF_MAX_ERRORS 10
1987
+ #else
1988
+ #define EXIF_MAX_ERRORS 100000
1989
+ #endif
1985
1990
1986
1991
/* {{{ exif_error_docref */
1987
1992
static void exif_error_docref (const char * docref EXIFERR_DC , image_info_type * ImageInfo , int type , const char * format , ...)
@@ -2003,7 +2008,7 @@ static void exif_error_docref(const char *docref EXIFERR_DC, image_info_type *Im
2003
2008
{
2004
2009
char * buf ;
2005
2010
2006
- spprintf (& buf , 0 , "%s(%d ): %s" , _file , _line , format );
2011
+ spprintf (& buf , 0 , "%s(%ld ): %s" , _file , _line , format );
2007
2012
php_verror (docref , ImageInfo && ImageInfo -> FileName ? ImageInfo -> FileName :"" , type , buf , args );
2008
2013
efree (buf );
2009
2014
}
@@ -2080,6 +2085,11 @@ static inline zend_bool exif_offset_info_contains(
2080
2085
return start >= info -> valid_start && end <= info -> valid_end ;
2081
2086
}
2082
2087
2088
+ static inline int exif_offset_info_length (const exif_offset_info * info )
2089
+ {
2090
+ return info -> valid_end - info -> valid_start ;
2091
+ }
2092
+
2083
2093
/* {{{ exif_file_sections_add
2084
2094
Add a file_section to image_info
2085
2095
returns the used block or -1. if size>0 and data == NULL buffer of size is allocated
@@ -2444,9 +2454,6 @@ static void add_assoc_image_info(zval *value, int sub_array, image_info_type *im
2444
2454
2445
2455
for (int i = 0 ; i < image_info -> info_list [section_index ].count ; i ++ ) {
2446
2456
image_info_data * info_data = & image_info -> info_list [section_index ].list [i ];
2447
- #ifdef EXIF_DEBUG
2448
- int info_tag = info_data -> tag ; /* conversion */
2449
- #endif
2450
2457
image_info_value * info_value = & info_data -> value ;
2451
2458
const char * name = info_data -> name ;
2452
2459
if (!name ) {
@@ -2846,9 +2853,6 @@ static void exif_thumbnail_build(image_info_type *ImageInfo) {
2846
2853
int i , byte_count ;
2847
2854
image_info_list * info_list ;
2848
2855
image_info_data * info_data ;
2849
- #ifdef EXIF_DEBUG
2850
- char tagname [64 ];
2851
- #endif
2852
2856
2853
2857
if (!ImageInfo -> read_thumbnail || !ImageInfo -> Thumbnail .offset || !ImageInfo -> Thumbnail .size ) {
2854
2858
return ; /* ignore this call */
@@ -3134,7 +3138,7 @@ static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * val
3134
3138
for (i = 0 ; i <=sizeof (maker_note_array )/sizeof (maker_note_type ); i ++ ) {
3135
3139
if (i == sizeof (maker_note_array )/sizeof (maker_note_type )) {
3136
3140
#ifdef EXIF_DEBUG
3137
- exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "No maker note data found. Detected maker: %s (length = %d)" , ImageInfo -> make , strlen (ImageInfo -> make ));
3141
+ exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "No maker note data found. Detected maker: %s (length = %d)" , ImageInfo -> make , ImageInfo -> make ? strlen (ImageInfo -> make ) : 0 );
3138
3142
#endif
3139
3143
/* unknown manufacturer, not an error, use it as a string */
3140
3144
return true;
@@ -3152,14 +3156,13 @@ static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * val
3152
3156
3153
3157
if (value_len < 2 || maker_note -> offset >= value_len - 1 ) {
3154
3158
/* Do not go past the value end */
3155
- exif_error_docref ("exif_read_data#error_ifd" EXIFERR_CC , ImageInfo , E_WARNING , "IFD data too short: 0x%04X offset 0x%04X" , value_len , maker_note -> offset );
3156
3159
return true;
3157
3160
}
3158
3161
3159
3162
dir_start = value_ptr + maker_note -> offset ;
3160
3163
3161
3164
#ifdef EXIF_DEBUG
3162
- exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "Process %s @x%04X + 0x%04X=%d: %s" , exif_get_sectionname (section_index ), (int )dir_start - (int ) offset_base + maker_note -> offset + displacement , value_len , value_len , exif_char_dump (value_ptr , value_len , (int )dir_start - (int ) offset_base + maker_note -> offset + displacement ));
3165
+ exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "Process %s @x%04X + 0x%04X=%d: %s" , exif_get_sectionname (section_index ), (intptr_t )dir_start - (intptr_t ) info -> offset_base + maker_note -> offset + displacement , value_len , value_len , exif_char_dump (value_ptr , value_len , (intptr_t )dir_start - (intptr_t ) info -> offset_base + maker_note -> offset + displacement ));
3163
3166
#endif
3164
3167
3165
3168
ImageInfo -> sections_found |= FOUND_MAKERNOTE ;
@@ -3315,8 +3318,10 @@ static bool exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, co
3315
3318
3316
3319
ImageInfo -> sections_found |= FOUND_ANY_TAG ;
3317
3320
#ifdef EXIF_DEBUG
3318
- dump_data = exif_dump_data (& dump_free , format , components , length , ImageInfo -> motorola_intel , value_ptr );
3319
- exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "Process tag(x%04X=%s,@x%04X + x%04X(=%d)): %s%s %s" , tag , exif_get_tagname_debug (tag , tag_table ), offset_val + displacement , byte_count , byte_count , (components > 1 )&& format != TAG_FMT_UNDEFINED && format != TAG_FMT_STRING ?"ARRAY OF " :"" , exif_get_tagformat (format ), dump_data );
3321
+ dump_data = exif_dump_data (& dump_free , format , components , ImageInfo -> motorola_intel , value_ptr );
3322
+ exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE ,
3323
+ "Process tag(x%04X=%s,@x%04X + x%04X(=%d)): %s%s %s" ,
3324
+ tag , exif_get_tagname_debug (tag , tag_table ), offset_val + displacement , byte_count , byte_count , (components > 1 )&& format != TAG_FMT_UNDEFINED && format != TAG_FMT_STRING ?"ARRAY OF " :"" , exif_get_tagformat (format ), dump_data );
3320
3325
if (dump_free ) {
3321
3326
efree (dump_data );
3322
3327
}
@@ -3561,7 +3566,7 @@ static bool exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start
3561
3566
int NextDirOffset = 0 ;
3562
3567
3563
3568
#ifdef EXIF_DEBUG
3564
- exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "Process %s (x%04X(=%d))" , exif_get_sectionname (section_index ), IFDlength , IFDlength );
3569
+ exif_error_docref (NULL EXIFERR_CC , ImageInfo , E_NOTICE , "Process %s (x%04X(=%d))" , exif_get_sectionname (section_index ), exif_offset_info_length ( info ), exif_offset_info_length ( info ) );
3565
3570
#endif
3566
3571
3567
3572
ImageInfo -> sections_found |= FOUND_IFD0 ;
0 commit comments