Skip to content

Commit 908c364

Browse files
committed
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: Added further notice about removal of IS_CONSTANT_INDEX/ARRAY macros Fix bug #67060: use default mode of 660 updated NEWS updated NEWS Fixed bug #66431 Special Character via COM Interface (CP_UTF8) Cleanup ZEND_MODULE_API_NO => 20050922 Fix crashes in GMP serialize/unserialize enable gmp for tests C89 compat
2 parents 92a73b0 + ba19cc7 commit 908c364

File tree

11 files changed

+134
-30
lines changed

11 files changed

+134
-30
lines changed

ext/com_dotnet/com_olechar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, php_size_t
4646

4747
if (string_len > 0) {
4848
olestring = (OLECHAR*)safe_emalloc(string_len, sizeof(OLECHAR), 0);
49+
/* XXX if that's a real multibyte string, olestring is obviously allocated excessively.
50+
This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't
51+
matter much. */
4952
ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
53+
if (ok > 0 && ok < string_len) {
54+
olestring[ok] = '\0';
55+
}
5056
} else {
5157
ok = FALSE;
5258
olestring = (OLECHAR*)emalloc(sizeof(OLECHAR));

ext/com_dotnet/com_variant.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, php_int_t
154154
case IS_STRING:
155155
V_VT(v) = VT_BSTR;
156156
olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRSIZE_P(z), codepage TSRMLS_CC);
157-
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRSIZE_P(z) * sizeof(OLECHAR));
157+
if (CP_UTF8 == codepage) {
158+
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, wcslen(olestring) * sizeof(OLECHAR));
159+
} else {
160+
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRSIZE_P(z) * sizeof(OLECHAR));
161+
}
158162
efree(olestring);
159163
break;
160164

ext/com_dotnet/tests/bug66431_0.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #66431 Special Character via COM Interface (CP_UTF8), Scripting.FileSystemObject
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present"; }
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$text= "Xin chào cộng đồng PHP";
11+
$fpath = str_replace("/", "\\", dirname(__FILE__) . "/bug66431.txt");
12+
13+
$fso = new COM("Scripting.FileSystemObject");
14+
$fh = $fso->OpenTextFile($fpath, 2, true);
15+
$fh->Write($text);
16+
$fh->Close();
17+
18+
$check_text = file_get_contents($fpath);
19+
20+
$result = ($check_text == $text);
21+
22+
var_dump($result);
23+
24+
if (!$result) {
25+
echo "Expected: '$check_text'\n";
26+
echo "Have: '$text'\n";
27+
}
28+
29+
?>
30+
===DONE===
31+
--CLEAN--
32+
<?php
33+
34+
$fpath = str_replace("/", "\\", dirname(__FILE__) . "/bug66431.txt");
35+
36+
if (file_exists($fpath)) {
37+
unlink($fpath);
38+
}
39+
?>
40+
--EXPECT--
41+
bool(true)
42+
===DONE===

ext/com_dotnet/tests/bug66431_1.phpt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
--TEST--
2+
Bug #66431 Special Character via COM Interface (CP_UTF8), Application.Word
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present"; }
6+
7+
try {
8+
new COM("word.application", NULL, CP_UTF8);
9+
} catch (Exception $e) {
10+
die('skip ' . $e->getMessage();
11+
}
12+
13+
?>
14+
--FILE--
15+
<?php
16+
17+
$text= "Xin chào cộng đồng PHP";
18+
$fpath = str_replace("/", "\\", dirname(__FILE__) . "/bug66431.docx");
19+
20+
com_load_typelib('Word.Application');
21+
22+
$Wrd = new COM("word.application", NULL, CP_UTF8);
23+
$Wrd->Documents->Add();
24+
$Wrd->Selection->TypeText($text);
25+
$Wrd->ActiveDocument->SaveAs($fpath);
26+
$Wrd->ActiveDocument->Close(false);
27+
$Wrd->Application->Quit();
28+
unset($Wrd);
29+
30+
$Wrd = new COM("word.application", NULL, CP_UTF8);
31+
$Wrd->Documents->Open($fpath, NULL, false);
32+
$check_text = $Wrd->ActiveDocument->Range($Wrd->ActiveDocument->Sentences(1)->Start, $Wrd->ActiveDocument->Sentences(1)->End)->Text;
33+
$Wrd->ActiveDocument->Close(false);
34+
$Wrd->Application->Quit();
35+
unset($Wrd);
36+
37+
/* trim the returned text as we'll get windows eol from a word doc. */
38+
$result = (trim($check_text) == $text);
39+
40+
var_dump($result);
41+
42+
if (!$result) {
43+
echo "Expected: '$check_text'\n";
44+
echo "Have: '$text'\n";
45+
}
46+
47+
?>
48+
===DONE===
49+
--CLEAN--
50+
<?php
51+
52+
$fpath = str_replace("/", "\\", dirname(__FILE__) . "/bug66431.docx");
53+
54+
if (file_exists($fpath)) {
55+
unlink($fpath);
56+
}
57+
?>
58+
--EXPECT--
59+
bool(true)
60+
===DONE===

ext/gmp/gmp.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -575,22 +575,20 @@ static int gmp_serialize(zval *object, unsigned char **buffer, php_size_t *buf_l
575575
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(object);
576576
smart_str buf = {0};
577577
zval zv, *zv_ptr = &zv;
578-
php_serialize_data_t *serialize_data = (php_serialize_data_t *) data;
579-
580-
PHP_VAR_SERIALIZE_INIT(*serialize_data);
578+
php_serialize_data_t serialize_data = (php_serialize_data_t) data;
581579

580+
PHP_VAR_SERIALIZE_INIT(serialize_data);
582581
INIT_PZVAL(zv_ptr);
583-
582+
584583
gmp_strval(zv_ptr, gmpnum, 10);
585-
php_var_serialize(&buf, &zv_ptr, serialize_data TSRMLS_CC);
584+
php_var_serialize(&buf, &zv_ptr, &serialize_data TSRMLS_CC);
586585
zval_dtor(zv_ptr);
587586

588587
Z_ARRVAL_P(zv_ptr) = zend_std_get_properties(object TSRMLS_CC);
589588
Z_TYPE_P(zv_ptr) = IS_ARRAY;
590-
php_var_serialize(&buf, &zv_ptr, serialize_data TSRMLS_CC);
591-
592-
PHP_VAR_SERIALIZE_DESTROY(*serialize_data);
589+
php_var_serialize(&buf, &zv_ptr, &serialize_data TSRMLS_CC);
593590

591+
PHP_VAR_SERIALIZE_DESTROY(serialize_data);
594592
*buffer = (unsigned char *) buf.c;
595593
*buf_len = buf.len;
596594

@@ -604,17 +602,16 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
604602
const unsigned char *p, *max;
605603
zval zv, *zv_ptr = &zv;
606604
int retval = FAILURE;
607-
php_unserialize_data_t *unserialize_data = (php_unserialize_data_t *) data;
608-
609-
PHP_VAR_UNSERIALIZE_INIT(*unserialize_data);
605+
php_unserialize_data_t unserialize_data = (php_unserialize_data_t) data;
610606

607+
PHP_VAR_UNSERIALIZE_INIT(unserialize_data);
611608
gmp_create_ex(*object, &gmpnum TSRMLS_CC);
612609

613610
p = buf;
614611
max = buf + buf_len;
615612

616613
INIT_ZVAL(zv);
617-
if (!php_var_unserialize(&zv_ptr, &p, max, unserialize_data TSRMLS_CC)
614+
if (!php_var_unserialize(&zv_ptr, &p, max, &unserialize_data TSRMLS_CC)
618615
|| Z_TYPE_P(zv_ptr) != IS_STRING
619616
|| convert_to_gmp(gmpnum, zv_ptr, 10 TSRMLS_CC) == FAILURE
620617
) {
@@ -624,7 +621,7 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
624621
zval_dtor(&zv);
625622

626623
INIT_ZVAL(zv);
627-
if (!php_var_unserialize(&zv_ptr, &p, max, unserialize_data TSRMLS_CC)
624+
if (!php_var_unserialize(&zv_ptr, &p, max, &unserialize_data TSRMLS_CC)
628625
|| Z_TYPE_P(zv_ptr) != IS_ARRAY
629626
) {
630627
zend_throw_exception(NULL, "Could not unserialize properties", 0 TSRMLS_CC);
@@ -641,7 +638,7 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
641638
retval = SUCCESS;
642639
exit:
643640
zval_dtor(&zv);
644-
PHP_VAR_UNSERIALIZE_DESTROY(*unserialize_data);
641+
PHP_VAR_UNSERIALIZE_DESTROY(unserialize_data);
645642
return retval;
646643
}
647644
/* }}} */

ext/pdo_firebird/firebird_driver.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,15 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, php_int_t attr, zval *v
567567
#else
568568
HMODULE l = GetModuleHandle("fbclient");
569569

570-
if (!l && !(l = GetModuleHandle("gds32"))) {
570+
if (!l) {
571571
break;
572572
}
573573
info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
574574
#endif
575575
if (info_func) {
576576
info_func(tmp);
577577
ZVAL_STRING(val,tmp,1);
578-
} else {
579-
ZVAL_STRING(val,"Firebird 1.0/Interbase 6",1);
580-
}
578+
}
581579
#else
582580
ZVAL_NULL(val);
583581
#endif

ext/pdo_firebird/pdo_firebird.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,15 @@ const zend_function_entry pdo_firebird_functions[] = { /* {{{ */
3535

3636
/* {{{ pdo_firebird_deps
3737
*/
38-
#if ZEND_MODULE_API_NO >= 20050922
3938
static const zend_module_dep pdo_firebird_deps[] = {
4039
ZEND_MOD_REQUIRED("pdo")
4140
ZEND_MOD_END
4241
};
43-
#endif
4442
/* }}} */
4543

4644
zend_module_entry pdo_firebird_module_entry = { /* {{{ */
47-
#if ZEND_MODULE_API_NO >= 20050922
4845
STANDARD_MODULE_HEADER_EX, NULL,
4946
pdo_firebird_deps,
50-
#else
51-
STANDARD_MODULE_HEADER,
52-
#endif
5347
"PDO_Firebird",
5448
pdo_firebird_functions,
5549
PHP_MINIT(pdo_firebird),

sapi/fpm/fpm/fpm_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
3939
/* uninitialized */
4040
wp->socket_uid = -1;
4141
wp->socket_gid = -1;
42-
wp->socket_mode = 0666;
42+
wp->socket_mode = 0660;
4343

4444
if (!c) {
4545
return 0;

sapi/fpm/php-fpm.conf.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ listen = 127.0.0.1:9000
166166
; permissions must be set in order to allow connections from a web server. Many
167167
; BSD-derived systems allow connections regardless of permissions.
168168
; Default Values: user and group are set as the running user
169-
; mode is set to 0666
169+
; mode is set to 0660
170170
;listen.owner = @php_fpm_user@
171171
;listen.group = @php_fpm_group@
172-
;listen.mode = 0666
172+
;listen.mode = 0660
173173

174174
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
175175
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original

sapi/phpdbg/phpdbg_watch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ PHPDBG_WATCH(array) /* {{{ */
464464

465465
void phpdbg_watch_HashTable_dtor(zval **zv) {
466466
phpdbg_btree_result *result;
467-
zval_ptr_dtor_wrapper(zv);
468467
TSRMLS_FETCH();
469468

469+
zval_ptr_dtor_wrapper(zv);
470470

471471
if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)*zv))) {
472472
phpdbg_watchpoint_t *watch = result->ptr;
@@ -772,9 +772,11 @@ void phpdbg_list_watchpoints(TSRMLS_D) {
772772
}
773773

774774
void phpdbg_watch_efree(void *ptr) {
775-
phpdbg_btree_result *result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr);
775+
phpdbg_btree_result *result;
776776
TSRMLS_FETCH();
777777

778+
result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr);
779+
778780
if (result) {
779781
phpdbg_watchpoint_t *watch = result->ptr;
780782

travis/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
--enable-sockets \
3535
--with-bz2 \
3636
--with-openssl \
37+
--with-gmp \
3738
--enable-bcmath
3839
make --quiet

0 commit comments

Comments
 (0)