Skip to content

Commit de5e8fc

Browse files
committed
Merge branch 'sccp' into dce
* sccp: (29 commits) Use existing bit Updated Windows build Fixed compilation error Remove debug code We need to check for the length here too, or we crash and no one likes that! :( * Implemented #65187 (exif_read_data/thumbnail: add support for stream resource) * ext/exif now uses FAST_ZPP Remove extraneous configure flag Revert "remove excessive checks and fix warnings" parametrize zip names Upgrade bundled PCRE to 8.41 Updated NEWS file with LDAP changes Fixed removing all controls by passing an empty array to ldap_set_option Filled in NEWS file with ext/ldap last modifications change order, allow to build as shared extension restore file deleted by mistake in a merge commit Fix segfault in php_stream_context_get_option call remove excessive checks and fix warnings fix macro redifinitions fix symbol availability and ws Remove this for now, as not found ...
2 parents 8c0de53 + 6595ea3 commit de5e8fc

File tree

121 files changed

+18128
-9029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+18128
-9029
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ environment:
2424
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
2525
PHP_BUILD_OBJ_DIR: c:\obj
2626
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
27-
PHP_BUILD_SDK_BRANCH: php-sdk-2.0.5
27+
PHP_BUILD_SDK_BRANCH: php-sdk-2.0.7
2828
PHP_BUILD_CRT: vc15
2929
# ext and env setup for tests
3030
#MYSQL_TEST_PASSWD: Password12!

EXTENSIONS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ MAINTENANCE: Maintained
419419
STATUS: Working
420420
SINCE: 4.0.2
421421
-------------------------------------------------------------------------------
422+
EXTENSION: sodium
423+
PRIMARY MAINTAINER: Frank Denis <jedisct1@php.net>
424+
MAINTENANCE: Maintained
425+
STATUS: Working
426+
SINCE: 7.2.0
427+
-------------------------------------------------------------------------------
422428
EXTENSION: spl
423429
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>, Etienne Kneuss <colder@php.net>
424430
MAINTENANCE: Maintained

NEWS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PHP NEWS
2121
(Andreas Treichel)
2222

2323
- EXIF:
24+
. Implemented #65187 (exif_read_data/thumbnail: add support for stream
25+
resource). (Kalle)
2426
. Deprecated the read_exif_data() alias. (Kalle)
2527
. Fixed bug #74428 (exif_read_data(): "Illegal IFD size" warning occurs with
2628
correct exif format). (bradpiccho at gmail dot com, Kalle)
@@ -37,6 +39,9 @@ PHP NEWS
3739
. Fixed bug #72324 (imap_mailboxmsginfo() return wrong size).
3840
(ronaldpoon at udomain dot com dot hk, Kalle)
3941

42+
- LDAP:
43+
. Fixed passing an empty array to ldap_set_option for client or server controls.
44+
4045
- OpenSSL:
4146
. Fixed bug #74651 (negative-size-param (-1) in memcpy in zif_openssl_seal()).
4247
(Stas)
@@ -45,12 +50,16 @@ PHP NEWS
4550
. Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()).
4651
(Dmitry)
4752

53+
- Sodium:
54+
. New cryptographic extension
55+
4856
- SQLite3:
4957
. Fixed bug #74883 (SQLite3::__construct() produces "out of memory" exception
5058
with invalid flags). (Anatol)
5159

5260
- ZIP:
5361
. ZipArchive implements countable, added ZipArchive::count() method. (Remi)
62+
. Fix segfault in php_stream_context_get_option call. (Remi)
5463

5564
06 Jul 2017, PHP 7.2.0alpha3
5665

@@ -72,6 +81,10 @@ PHP NEWS
7281
. Fixed bug #74849 (Process is started as interactive shell in PhpStorm).
7382
(Anatol)
7483

84+
- LDAP:
85+
. Implemented FR #69445 (Support for LDAP EXOP operations)
86+
. Fixed support for LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS in ldap_get_option
87+
7588
- OpenSSL:
7689
. Fixed bug #74798 (pkcs7_en/decrypt does not work if \x0a is used in content).
7790
(Anatol)

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ PHP 7.2 UPGRADE NOTES
124124
subpatterns and empty matches by reporting NULL and "" (empty string),
125125
respectively.
126126

127+
- Sodium
128+
. New cryptographic extension
129+
127130
- SQLite3:
128131
. Implemented writing to BLOBs.
129132

@@ -270,6 +273,8 @@ See also: https://wiki.php.net/rfc/deprecations_php_7_2
270273
. Added extended exif tag support for the following formats:
271274
Samsung, DJI, Panasonic, Sony, Pentax, Minolta, Sigma/Foveon,
272275
AGFA, Kyocera, Ricoh & Epson.
276+
. exif_read_data() and exif_thumbnail() now supports a passed streams as their
277+
first parameter.
273278

274279
- GD:
275280
. Removed --enable-gd-native-ttf configuration option which was unused as

ext/exif/exif.c

Lines changed: 119 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,33 +4305,35 @@ static int exif_discard_imageinfo(image_info_type *ImageInfo)
43054305
}
43064306
/* }}} */
43074307

4308-
/* {{{ exif_read_file
4308+
/* {{{ exif_read_from_stream
43094309
*/
4310-
static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int read_all)
4310+
static int exif_read_from_stream(image_info_type *ImageInfo, php_stream *stream, int read_thumbnail, int read_all)
43114311
{
43124312
int ret;
43134313
zend_stat_t st;
4314-
zend_string *base;
43154314

43164315
/* Start with an empty image information structure. */
43174316
memset(ImageInfo, 0, sizeof(*ImageInfo));
43184317

4319-
ImageInfo->motorola_intel = -1; /* flag as unknown */
4320-
4321-
ImageInfo->infile = php_stream_open_wrapper(FileName, "rb", STREAM_MUST_SEEK|IGNORE_PATH, NULL);
4322-
if (!ImageInfo->infile) {
4323-
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file");
4324-
return FALSE;
4325-
}
4318+
ImageInfo->motorola_intel = -1; /* flag as unknown */
4319+
ImageInfo->infile = stream;
4320+
ImageInfo->FileName = NULL;
43264321

43274322
if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) {
4328-
if (VCWD_STAT(FileName, &st) >= 0) {
4323+
if (VCWD_STAT(stream->orig_path, &st) >= 0) {
4324+
zend_string *base;
43294325
if ((st.st_mode & S_IFMT) != S_IFREG) {
43304326
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file");
43314327
php_stream_close(ImageInfo->infile);
43324328
return FALSE;
43334329
}
43344330

4331+
/* Store file name */
4332+
base = php_basename(stream->orig_path, strlen(stream->orig_path), NULL, 0);
4333+
ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base));
4334+
4335+
zend_string_release(base);
4336+
43354337
/* Store file date/time. */
43364338
ImageInfo->FileDateTime = st.st_mtime;
43374339
ImageInfo->FileSize = st.st_size;
@@ -4345,51 +4347,76 @@ static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_t
43454347
}
43464348
}
43474349

4348-
base = php_basename(FileName, strlen(FileName), NULL, 0);
4349-
ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base));
4350-
zend_string_release(base);
4351-
ImageInfo->read_thumbnail = read_thumbnail;
4352-
ImageInfo->read_all = read_all;
4353-
ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN;
4350+
ImageInfo->read_thumbnail = read_thumbnail;
4351+
ImageInfo->read_all = read_all;
4352+
ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN;
43544353

4355-
ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode));
4356-
ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be));
4357-
ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le));
4358-
ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis));
4359-
ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be));
4360-
ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le));
4354+
ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode));
4355+
ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be));
4356+
ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le));
4357+
ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis));
4358+
ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be));
4359+
ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le));
43614360

43624361

43634362
ImageInfo->ifd_nesting_level = 0;
43644363

4365-
/* Scan the JPEG headers. */
4364+
/* Scan the headers */
43664365
ret = exif_scan_FILE_header(ImageInfo);
43674366

4368-
php_stream_close(ImageInfo->infile);
43694367
return ret;
43704368
}
43714369
/* }}} */
43724370

4373-
/* {{{ proto array exif_read_data(string filename [, string sections_needed [, bool sub_arrays[, bool read_thumbnail]]])
4374-
Reads header data from the JPEG/TIFF image filename and optionally reads the internal thumbnails */
4375-
PHP_FUNCTION(exif_read_data)
4371+
/* {{{ exif_read_from_file
4372+
*/
4373+
static int exif_read_from_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int read_all)
43764374
{
4377-
char *p_name, *p_sections_needed = NULL;
4378-
size_t p_name_len, p_sections_needed_len = 0;
4379-
zend_bool sub_arrays=0, read_thumbnail=0, read_all=0;
4375+
int ret;
4376+
php_stream *stream;
4377+
4378+
stream = php_stream_open_wrapper(FileName, "rb", STREAM_MUST_SEEK | IGNORE_PATH, NULL);
4379+
4380+
if (!stream) {
4381+
memset(&ImageInfo, 0, sizeof(ImageInfo));
4382+
4383+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file");
4384+
4385+
return FALSE;
4386+
}
4387+
4388+
ret = exif_read_from_stream(ImageInfo, stream, read_thumbnail, read_all);
4389+
4390+
php_stream_close(stream);
4391+
4392+
return ret;
4393+
}
4394+
/* }}} */
43804395

4381-
int i, ret, sections_needed=0;
4396+
/* {{{ proto array exif_read_data(mixed stream [, string sections_needed [, bool sub_arrays[, bool read_thumbnail]]])
4397+
Reads header data from an image and optionally reads the internal thumbnails */
4398+
PHP_FUNCTION(exif_read_data)
4399+
{
4400+
zend_string *z_sections_needed = NULL;
4401+
zend_bool sub_arrays = 0, read_thumbnail = 0, read_all = 0;
4402+
zval *stream;
4403+
int i, ret, sections_needed = 0;
43824404
image_info_type ImageInfo;
43834405
char tmp[64], *sections_str, *s;
43844406

4385-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|sbb", &p_name, &p_name_len, &p_sections_needed, &p_sections_needed_len, &sub_arrays, &read_thumbnail) == FAILURE) {
4386-
return;
4387-
}
4407+
/* Parse arguments */
4408+
ZEND_PARSE_PARAMETERS_START(1, 4)
4409+
Z_PARAM_ZVAL(stream)
4410+
Z_PARAM_OPTIONAL
4411+
Z_PARAM_STR(z_sections_needed)
4412+
Z_PARAM_BOOL(sub_arrays)
4413+
Z_PARAM_BOOL(read_thumbnail)
4414+
ZEND_PARSE_PARAMETERS_END();
43884415

43894416
memset(&ImageInfo, 0, sizeof(ImageInfo));
43904417

4391-
if (p_sections_needed) {
4392-
spprintf(&sections_str, 0, ",%s,", p_sections_needed);
4418+
if (z_sections_needed) {
4419+
spprintf(&sections_str, 0, ",%s,", ZSTR_VAL(z_sections_needed));
43934420
/* sections_str DOES start with , and SPACES are NOT allowed in names */
43944421
s = sections_str;
43954422
while (*++s) {
@@ -4409,19 +4436,39 @@ PHP_FUNCTION(exif_read_data)
44094436
#ifdef EXIF_DEBUG
44104437
sections_str = exif_get_sectionlist(sections_needed);
44114438
if (!sections_str) {
4439+
zend_string_release(z_sections_needed);
44124440
RETURN_FALSE;
44134441
}
44144442
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? sections_str : "None");
44154443
EFREE_IF(sections_str);
44164444
#endif
4445+
zend_string_release(z_sections_needed);
4446+
}
4447+
4448+
if (Z_TYPE_P(stream) == IS_RESOURCE) {
4449+
php_stream *p_stream = NULL;
4450+
4451+
php_stream_from_res(p_stream, Z_RES_P(stream));
4452+
4453+
ret = exif_read_from_stream(&ImageInfo, p_stream, read_thumbnail, read_all);
4454+
} else {
4455+
convert_to_string(stream);
4456+
4457+
if (!Z_STRLEN_P(stream)) {
4458+
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_WARNING, "Filename cannot be empty");
4459+
4460+
RETURN_FALSE;
4461+
}
4462+
4463+
ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), read_thumbnail, read_all);
44174464
}
44184465

4419-
ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all);
44204466
sections_str = exif_get_sectionlist(ImageInfo.sections_found);
44214467

44224468
#ifdef EXIF_DEBUG
4423-
if (sections_str)
4469+
if (sections_str) {
44244470
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? sections_str : "None");
4471+
}
44254472
#endif
44264473

44274474
ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/
@@ -4552,24 +4599,41 @@ PHP_FUNCTION(exif_read_data)
45524599
Reads the embedded thumbnail */
45534600
PHP_FUNCTION(exif_thumbnail)
45544601
{
4555-
zval *p_width = 0, *p_height = 0, *p_imagetype = 0;
4556-
char *p_name;
4557-
size_t p_name_len;
45584602
int ret, arg_c = ZEND_NUM_ARGS();
45594603
image_info_type ImageInfo;
4604+
zval *stream;
4605+
zval *z_width = NULL, *z_height = NULL, *z_imagetype = NULL;
4606+
4607+
/* Parse arguments */
4608+
ZEND_PARSE_PARAMETERS_START(1, 4)
4609+
Z_PARAM_ZVAL(stream)
4610+
Z_PARAM_OPTIONAL
4611+
Z_PARAM_ZVAL_DEREF(z_width)
4612+
Z_PARAM_ZVAL_DEREF(z_height)
4613+
Z_PARAM_ZVAL_DEREF(z_imagetype)
4614+
ZEND_PARSE_PARAMETERS_END();
45604615

45614616
memset(&ImageInfo, 0, sizeof(ImageInfo));
45624617

4563-
if (arg_c!=1 && arg_c!=3 && arg_c!=4) {
4564-
WRONG_PARAM_COUNT;
4565-
}
4618+
if (Z_TYPE_P(stream) == IS_RESOURCE) {
4619+
php_stream *p_stream = NULL;
45664620

4567-
if (zend_parse_parameters(arg_c, "p|z/z/z/", &p_name, &p_name_len, &p_width, &p_height, &p_imagetype) == FAILURE) {
4568-
return;
4621+
php_stream_from_res(p_stream, Z_RES_P(stream));
4622+
4623+
ret = exif_read_from_stream(&ImageInfo, p_stream, 1, 0);
4624+
} else {
4625+
convert_to_string(stream);
4626+
4627+
if (!Z_STRLEN_P(stream)) {
4628+
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_WARNING, "Filename cannot be empty");
4629+
4630+
RETURN_FALSE;
4631+
}
4632+
4633+
ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), 1, 0);
45694634
}
45704635

4571-
ret = exif_read_file(&ImageInfo, p_name, 1, 0);
4572-
if (ret==FALSE) {
4636+
if (ret == FALSE) {
45734637
exif_discard_imageinfo(&ImageInfo);
45744638
RETURN_FALSE;
45754639
}
@@ -4591,14 +4655,14 @@ PHP_FUNCTION(exif_thumbnail)
45914655
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
45924656
exif_scan_thumbnail(&ImageInfo);
45934657
}
4594-
zval_dtor(p_width);
4595-
zval_dtor(p_height);
4596-
ZVAL_LONG(p_width, ImageInfo.Thumbnail.width);
4597-
ZVAL_LONG(p_height, ImageInfo.Thumbnail.height);
4658+
zval_dtor(z_width);
4659+
zval_dtor(z_height);
4660+
ZVAL_LONG(z_width, ImageInfo.Thumbnail.width);
4661+
ZVAL_LONG(z_height, ImageInfo.Thumbnail.height);
45984662
}
45994663
if (arg_c >= 4) {
4600-
zval_dtor(p_imagetype);
4601-
ZVAL_LONG(p_imagetype, ImageInfo.Thumbnail.filetype);
4664+
zval_dtor(z_imagetype);
4665+
ZVAL_LONG(z_imagetype, ImageInfo.Thumbnail.filetype);
46024666
}
46034667

46044668
#ifdef EXIF_DEBUG

0 commit comments

Comments
 (0)