Skip to content

Commit 1b43f95

Browse files
committed
Merged PR #293 (Exif crash on unknown encoding was fixed)
By: Draal Conflicts: configure.in main/php_version.h
1 parent 2ecf94e commit 1b43f95

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

ext/exif/exif.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -2643,14 +2643,15 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
26432643
} else {
26442644
decode = ImageInfo->decode_unicode_le;
26452645
}
2646+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
26462647
if (zend_multibyte_encoding_converter(
26472648
(unsigned char**)pszInfoPtr,
26482649
&len,
26492650
(unsigned char*)szValuePtr,
26502651
ByteCount,
26512652
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
26522653
zend_multibyte_fetch_encoding(decode TSRMLS_CC)
2653-
TSRMLS_CC) < 0) {
2654+
TSRMLS_CC) == (size_t)-1) {
26542655
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
26552656
}
26562657
return len;
@@ -2663,14 +2664,15 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
26632664
*pszEncoding = estrdup((const char*)szValuePtr);
26642665
szValuePtr = szValuePtr+8;
26652666
ByteCount -= 8;
2667+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
26662668
if (zend_multibyte_encoding_converter(
26672669
(unsigned char**)pszInfoPtr,
26682670
&len,
26692671
(unsigned char*)szValuePtr,
26702672
ByteCount,
26712673
zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC),
26722674
zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC)
2673-
TSRMLS_CC) < 0) {
2675+
TSRMLS_CC) == (size_t)-1) {
26742676
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
26752677
}
26762678
return len;
@@ -2700,16 +2702,16 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
27002702
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
27012703
{
27022704
xp_field->tag = tag;
2703-
2704-
/* Copy the comment */
2705+
2706+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
27052707
if (zend_multibyte_encoding_converter(
27062708
(unsigned char**)&xp_field->value,
27072709
&xp_field->size,
27082710
(unsigned char*)szValuePtr,
27092711
ByteCount,
27102712
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
27112713
zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo->decode_unicode_le TSRMLS_CC)
2712-
TSRMLS_CC) < 0) {
2714+
TSRMLS_CC) == (size_t)-1) {
27132715
xp_field->size = exif_process_string_raw(&xp_field->value, szValuePtr, ByteCount);
27142716
}
27152717
return xp_field->size;
7.42 KB
Loading
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
PHP crash when zend_multibyte_encoding_converter returns (size_t)-1)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
$infile = dirname(__FILE__).'/exif_encoding_crash.jpg';
8+
$exif_data = exif_read_data($infile);
9+
echo "*** no core dump ***\n";
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
*** no core dump ***
14+
===DONE===

0 commit comments

Comments
 (0)