1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 22:22:18 +02:00

Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5

This commit is contained in:
Xinchen Hui
2014-08-11 17:44:42 +08:00
50 changed files with 14727 additions and 13969 deletions

4
.gitattributes vendored
View File

@@ -22,6 +22,10 @@ sapi/nsapi/nsapi.c ident
sapi/continuity/capi.c ident
Zend/RFCs/002.txt ident
Zend/RFCs/003.txt ident
ext/exif/exif.c ident
ext/ldap/ldap.c ident
ext/pdo_pgsql/pdo_pgsql.c ident
ext/tidy/tidy.c ident
NEWS merge=NEWS
UPGRADING merge=NEWS
UPGRADING.INTERNALS merge=NEWS

54
NEWS
View File

@@ -1,9 +1,55 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2014, PHP 5.5.17
- OpenSSL:
. Fixed bug #41631 (socket timeouts not honored in blocking SSL reads)
(Daniel Lowrey).
?? ??? 2014, PHP 5.5.16
- COM:
. Fixed missing type checks in com_event_sink (Yussuf Khalil, Stas).
?? ??? 2014, PHP 5.5.15
- Fileinfo:
. Fixed bug #67705 (extensive backtracking in rule regular expression).
(CVE-2014-3538) (Remi)
- FPM:
. Fixed bug #67635 (php links to systemd libraries without using pkg-config).
(pacho@gentoo.org, Remi)
- GD:
. Fixed bug #66901 (php-gd 'c_color' NULL pointer dereference).
(CVE-2014-2497) (Remi)
- Milter:
. Fixed bug #67715 (php-milter does not build and crashes randomly). (Mike)
- OpenSSL:
. Fixed missing type checks in OpenSSL options (Yussuf Khalil, Stas).
- readline:
. Fixed bug #55496 (Interactive mode doesn't force a newline before the
prompt). (Bob, Johannes)
. Fixed bug #67496 (Save command history when exiting interactive shell
with control-c). (Dmitry Saprykin, Johannes)
- Sessions:
. Fixed missing type checks in php_session_create_id (Yussuf Khalil, Stas).
- Core:
. Fixed bug #67693 (incorrect push to the empty array) (Tjerk)
- ODBC:
. Fixed bug #60616 (odbc_fetch_into returns junk data at end of multi-byte
char fields). (Keyur)
- Zlib:
. Fixed bug #67724 (chained zlib filters silently fail with large amounts of
data). (Mike)
24 Jul 2014, PHP 5.5.15
- Core:
. Fixed bug #67428 (header('Location: foo') will override a 308-399 response
@@ -52,12 +98,16 @@ PHP NEWS
- SPL:
. Fixed bug #67539 (ArrayIterator use-after-free due to object change during
sorting). (research at insighti dot org, Laruence)
sorting). (CVE-2014-4698) (research at insighti dot org, Laruence)
. Fixed bug #67538 (SPL Iterators use-after-free). (CVE-2014-4670) (Laruence)
- Streams:
. Fixed bug #67430 (http:// wrapper doesn't follow 308 redirects). (Adam)
- Session:
. Fixed bug #66827 (Session raises E_NOTICE when session name variable is array).
(Yasuo)
27 Jun 2014, PHP 5.5.14
- Core:

View File

@@ -5,28 +5,56 @@ Bug #66608 (Incorrect behavior with nested "finally" blocks)
function bar() {
try {
echo "1\n";
try {
} finally {
try {
} finally {
}
echo "2\n";
}
} finally {
try {
throw new Exception ("");
} catch (Exception $ab) {
echo "2\n";
echo "3\n";
} finally {
try {
} finally {
echo "3\n";
echo "4\n";
try {
} finally {
}
echo "4\n";
echo "5\n";
}
}
echo "5\n";
echo "6\n";
try {
} finally {
echo "6\n";
while (1) {
try {
echo "7\n";
break;
} finally {
echo "8\n";
}
echo "bad";
}
echo "9\n";
while (1) {
try {
throw new Exception("");
} catch(Exception $e) {
echo "10\n";
break;
} finally {
echo "11\n";
}
echo "bak\n";
}
}
echo "12\n";
}
echo "7\n";
echo "13\n";
}
bar();
--EXPECT--
@@ -37,3 +65,9 @@ bar();
5
6
7
8
9
10
11
12
13

View File

@@ -0,0 +1,15 @@
--TEST--
Try finally (segfault with empty break)
--FILE--
<?php
function foo () {
try {
break;
} finally {
}
}
foo();
?>
--EXPECTF--
Fatal error: Cannot break/continue 1 level in %stry_finally_011.php on line %d

View File

@@ -843,8 +843,8 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC);
#define ZEND_FAST_RET_TO_CATCH 1
#define ZEND_FAST_RET_TO_FINALLY 2
#define ZEND_FAST_CALL_FOR_CATCH 1
#define ZEND_FAST_CALL_FOR_FINALLY 2
#define ZEND_FAST_CALL_FROM_CATCH 1
#define ZEND_FAST_CALL_FROM_FINALLY 2
END_EXTERN_C()

View File

@@ -509,6 +509,49 @@ static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_nu
}
}
static void zend_adjust_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint start, zend_uint end TSRMLS_DC)
{
int i;
zend_uint op_num = 0;
for (i = 0; i < op_array->last_try_catch; i++) {
if (op_array->try_catch_array[i].finally_op > start
&& op_array->try_catch_array[i].finally_end < end) {
op_num = op_array->try_catch_array[i].finally_op;
start = op_array->try_catch_array[i].finally_end;
}
}
if (op_num) {
/* Must be ZEND_FAST_CALL */
ZEND_ASSERT(op_array->opcodes[op_num - 2].opcode == ZEND_FAST_CALL);
op_array->opcodes[op_num - 2].extended_value = ZEND_FAST_CALL_FROM_FINALLY;
op_array->opcodes[op_num - 2].op2.opline_num = fast_call;
}
}
static void zend_resolve_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint op_num TSRMLS_DC)
{
int i;
zend_uint finally_op_num = 0;
for (i = 0; i < op_array->last_try_catch; i++) {
if (op_num >= op_array->try_catch_array[i].finally_op
&& op_num < op_array->try_catch_array[i].finally_end) {
finally_op_num = op_array->try_catch_array[i].finally_op;
}
}
if (finally_op_num) {
/* Must be ZEND_FAST_CALL */
ZEND_ASSERT(op_array->opcodes[finally_op_num - 2].opcode == ZEND_FAST_CALL);
if (op_array->opcodes[fast_call].extended_value == 0) {
op_array->opcodes[fast_call].extended_value = ZEND_FAST_CALL_FROM_FINALLY;
op_array->opcodes[fast_call].op2.opline_num = finally_op_num - 2;
}
}
}
static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num, zend_uint dst_num TSRMLS_DC)
{
zend_uint start_op;
@@ -536,11 +579,23 @@ static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num,
opline->opcode = ZEND_FAST_CALL;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
opline->op1.opline_num = op_array->try_catch_array[i].finally_op;
zend_adjust_fast_call(op_array, start_op,
op_array->try_catch_array[i].finally_op,
op_array->try_catch_array[i].finally_end TSRMLS_CC);
if (op_array->try_catch_array[i].catch_op) {
opline->extended_value = ZEND_FAST_CALL_FOR_CATCH;
opline->extended_value = ZEND_FAST_CALL_FROM_CATCH;
opline->op2.opline_num = op_array->try_catch_array[i].catch_op;
opline->op1.opline_num = get_next_op_number(op_array);
/* generate a FAST_CALL to hole CALL_FROM_FINALLY */
opline = get_next_op(op_array TSRMLS_CC);
opline->opcode = ZEND_FAST_CALL;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
zend_resolve_fast_call(op_array, start_op + 1, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC);
} else {
zend_resolve_fast_call(op_array, start_op, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC);
}
opline->op1.opline_num = op_array->try_catch_array[i].finally_op;
/* generate a sequence of FAST_CALL to upward finally block */
while (i > 0) {
@@ -603,32 +658,12 @@ static void zend_resolve_finally_ret(zend_op_array *op_array, zend_uint op_num T
}
}
static void zend_resolve_fast_call(zend_op_array *op_array, zend_uint op_num TSRMLS_DC)
{
int i;
zend_uint finally_op_num = 0;
for (i = 0; i < op_array->last_try_catch; i++) {
if (op_array->try_catch_array[i].finally_op > op_num) {
break;
}
if (op_num < op_array->try_catch_array[i].finally_end) {
finally_op_num = op_array->try_catch_array[i].finally_op;
}
}
if (finally_op_num) {
op_array->opcodes[op_num].extended_value = ZEND_FAST_CALL_FOR_FINALLY;
op_array->opcodes[op_num].op2.opline_num = finally_op_num - 2; /* it must be ZEND_FAST_CALL */
}
}
static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
{
zend_uint i;
zend_uint i, j;
zend_op *opline;
for (i = 0; i < op_array->last; i++) {
for (i = 0, j = op_array->last; i < j; i++) {
opline = op_array->opcodes + i;
switch (opline->opcode) {
case ZEND_RETURN:
@@ -643,15 +678,16 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
zend_brk_cont_element *jmp_to;
nest_levels = Z_LVAL(op_array->literals[opline->op2.constant].constant);
array_offset = opline->op1.opline_num;
do {
jmp_to = &op_array->brk_cont_array[array_offset];
if (nest_levels > 1) {
array_offset = jmp_to->parent;
}
} while (--nest_levels > 0);
zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC);
break;
if ((array_offset = opline->op1.opline_num) != -1) {
do {
jmp_to = &op_array->brk_cont_array[array_offset];
if (nest_levels > 1) {
array_offset = jmp_to->parent;
}
} while (--nest_levels > 0);
zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC);
break;
}
}
case ZEND_GOTO:
if (Z_TYPE(op_array->literals[opline->op2.constant].constant) != IS_LONG) {
@@ -665,7 +701,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
zend_resolve_finally_call(op_array, i, opline->op1.opline_num TSRMLS_CC);
break;
case ZEND_FAST_CALL:
zend_resolve_fast_call(op_array, i TSRMLS_CC);
zend_resolve_fast_call(op_array, i, i TSRMLS_CC);
break;
case ZEND_FAST_RET:
zend_resolve_finally_ret(op_array, i TSRMLS_CC);

View File

@@ -5396,7 +5396,7 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY)
{
USE_OPLINE
if ((opline->extended_value & ZEND_FAST_CALL_FOR_CATCH) &&
if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) &&
UNEXPECTED(EG(prev_exception) != NULL)) {
/* in case of unhandled exception jump to catch block instead of finally */
ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]);
@@ -5411,7 +5411,7 @@ ZEND_VM_HANDLER(163, ZEND_FAST_RET, ANY, ANY)
{
if (EX(fast_ret)) {
ZEND_VM_SET_OPCODE(EX(fast_ret) + 1);
if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FOR_FINALLY)) {
if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) {
EX(fast_ret) = &EX(op_array)->opcodes[EX(fast_ret)->op2.opline_num];
}
ZEND_VM_CONTINUE();

View File

@@ -1137,7 +1137,7 @@ static int ZEND_FASTCALL ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
if ((opline->extended_value & ZEND_FAST_CALL_FOR_CATCH) &&
if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) &&
UNEXPECTED(EG(prev_exception) != NULL)) {
/* in case of unhandled exception jump to catch block instead of finally */
ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]);
@@ -1152,7 +1152,7 @@ static int ZEND_FASTCALL ZEND_FAST_RET_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
if (EX(fast_ret)) {
ZEND_VM_SET_OPCODE(EX(fast_ret) + 1);
if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FOR_FINALLY)) {
if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) {
EX(fast_ret) = &EX(op_array)->opcodes[EX(fast_ret)->op2.opline_num];
}
ZEND_VM_CONTINUE();

View File

@@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=5
PHP_RELEASE_VERSION=15
PHP_RELEASE_VERSION=17
PHP_EXTRA_VERSION="-dev"
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`

View File

@@ -698,9 +698,9 @@ PHP_FUNCTION(com_event_sink)
/* 0 => typelibname, 1 => dispname */
zval **tmp;
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS)
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
typelibname = Z_STRVAL_PP(tmp);
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS)
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
dispname = Z_STRVAL_PP(tmp);
} else if (sink != NULL) {
convert_to_string(sink);

File diff suppressed because it is too large Load Diff

View File

@@ -931,8 +931,8 @@ mssqltime = hour12 ":" minutelz ":" secondlz [:.] [0-9]+ meridian;
isoweekday = year4 "-"? "W" weekofyear "-"? [0-7];
isoweek = year4 "-"? "W" weekofyear;
exif = year4 ":" monthlz ":" daylz " " hour24lz ":" minutelz ":" secondlz;
firstdayof = 'first day of'?;
lastdayof = 'last day of'?;
firstdayof = 'first day of';
lastdayof = 'last day of';
backof = 'back of ' hour24 space? meridian?;
frontof = 'front of ' hour24 space? meridian?;

File diff suppressed because it is too large Load Diff

View File

@@ -115198,7 +115198,7 @@ const unsigned char php_magic_database[2606480] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x3D, 0x1B, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x5E, 0x5C, 0x73, 0x7B, 0x30, 0x2C, 0x31, 0x30, 0x30, 0x7D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x5C,
0x73, 0x7B, 0x30, 0x2C, 0x31, 0x30, 0x30, 0x7D, 0x5B, 0x7B, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@@ -58,7 +58,7 @@ private int32_t mprint(struct magic_set *, struct magic *);
private int32_t moffset(struct magic_set *, struct magic *);
private void mdebug(uint32_t, const char *, size_t);
private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
const unsigned char *, uint32_t, size_t, size_t);
const unsigned char *, uint32_t, size_t, struct magic *);
private int mconvert(struct magic_set *, struct magic *, int);
private int print_sep(struct magic_set *, int);
private int handle_annotation(struct magic_set *, struct magic *);
@@ -1003,7 +1003,7 @@ mdebug(uint32_t offset, const char *str, size_t len)
private int
mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt)
const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m)
{
/*
* Note: FILE_SEARCH and FILE_REGEX do not actually copy
@@ -1023,15 +1023,24 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
const char *last; /* end of search region */
const char *buf; /* start of search region */
const char *end;
size_t lines;
size_t lines, linecnt, bytecnt;
linecnt = m->str_range;
bytecnt = linecnt * 80;
if (bytecnt == 0) {
bytecnt = 8192;
}
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL;
return 0;
}
buf = RCAST(const char *, s) + offset;
end = last = RCAST(const char *, s) + nbytes;
end = last = RCAST(const char *, s) + bytecnt;
/* mget() guarantees buf <= last */
for (lines = linecnt, b = buf; lines && b < end &&
((b = CAST(const char *,
@@ -1044,7 +1053,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
b++;
}
if (lines)
last = RCAST(const char *, s) + nbytes;
last = RCAST(const char *, s) + bytecnt;
ms->search.s = buf;
ms->search.s_len = last - buf;
@@ -1118,7 +1127,6 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
int *need_separator, int *returnval)
{
uint32_t soffset, offset = ms->offset;
uint32_t count = m->str_range;
int rv, oneed_separator;
char *sbuf, *rbuf;
union VALUETYPE *p = &ms->ms_value;
@@ -1130,13 +1138,12 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
}
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
(uint32_t)nbytes, count) == -1)
(uint32_t)nbytes, m) == -1)
return -1;
if ((ms->flags & MAGIC_DEBUG) != 0) {
fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
"nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
nbytes, count);
"nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes);
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
}
@@ -1627,7 +1634,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect +offs=%u\n", offset);
}
if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1)
return -1;
ms->offset = offset;
@@ -2057,7 +2064,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
zval *retval;
zval *subpats;
char *haystack;
MAKE_STD_ZVAL(retval);
ALLOC_INIT_ZVAL(subpats);

View File

@@ -1,4 +1,4 @@
Patches applied to file sources tree before generating magic.mgc
Patches applied to file 5.14 sources tree before generating magic.mgc
and before running create_data_file.php to create data_file.c.
@@ -17,14 +17,6 @@ diff --git a/magic/Magdir/commands b/magic/Magdir/commands
index 67c3eee..4a7d8dd 100644
--- a/magic/Magdir/commands
+++ b/magic/Magdir/commands
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
-# $File: commands,v 1.44 2013/02/05 15:20:47 christos Exp $
+# $File: commands,v 1.45 2013/02/06 14:18:52 christos Exp $
# commands: file(1) magic for various shells and interpreters
#
#0 string/w : shell archive or script for antique kernel text
@@ -49,7 +49,7 @@
!:mime text/x-awk
0 string/wt #!\ /usr/bin/awk awk script text executable
@@ -36,4 +28,56 @@ index 67c3eee..4a7d8dd 100644
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
--
1.8.5.5
From 0b478f445b6b7540b58af5d1fe583fa9e48fd745 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Wed, 28 May 2014 19:52:36 +0000
Subject: [PATCH] further optimize awk by not looking for the BEGIN regex until
we found the BEGIN (Jan Kaluza)
---
magic/Magdir/commands | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
index bfffdef..26b2869 100644
--- a/magic/Magdir/commands
+++ b/magic/Magdir/commands
@@ -49,7 +49,8 @@
!:mime text/x-awk
0 string/wt #!\ /usr/bin/awk awk script text executable
!:mime text/x-awk
-0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
+0 search/16384 BEGIN
+>0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
# AT&T Bell Labs' Plan 9 shell
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
--
2.0.3
From 71a8b6c0d758acb0f73e2e51421a711b5e9d6668 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Fri, 30 May 2014 16:48:44 +0000
Subject: [PATCH] Limit regex search for BEGIN to the first 4K of the file.
---
magic/Magdir/commands | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
index 26b2869..bcd0f43 100644
--- a/magic/Magdir/commands
+++ b/magic/Magdir/commands
@@ -49,8 +49,7 @@
!:mime text/x-awk
0 string/wt #!\ /usr/bin/awk awk script text executable
!:mime text/x-awk
-0 search/16384 BEGIN
->0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
+0 regex/4096 =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
# AT&T Bell Labs' Plan 9 shell
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
--
2.0.3

View File

@@ -0,0 +1,35 @@
--TEST--
Bug #66731: file: extensive backtraking
--SKIPIF--
<?php
if (!class_exists('finfo'))
die('skip no fileinfo extension');
--FILE--
<?php
$fd = __DIR__.'/cve-2014-3538.data';
file_put_contents($fd,
'try:' .
str_repeat("\n", 1000000));
$fi = finfo_open(FILEINFO_NONE);
$t = microtime(true);
var_dump(finfo_file($fi, $fd));
$t = microtime(true) - $t;
finfo_close($fi);
if ($t < 1) {
echo "Ok\n";
} else {
printf("Failed, time=%.2f\n", $t);
}
?>
Done
--CLEAN--
<?php
@unlink(__DIR__.'/cve-2014-3538.data');
?>
--EXPECTF--
string(%d) "%s"
Ok
Done

View File

@@ -31,12 +31,17 @@ gdImagePtr gdImageCreateFromXpm (char *filename)
if (ret != XpmSuccess) {
return 0;
}
number = image.ncolors;
for(i = 0; i < number; i++) {
if (!image.colorTable[i].c_color) {
goto done;
}
}
if (!(im = gdImageCreate(image.width, image.height))) {
goto done;
}
number = image.ncolors;
colors = (int *) safe_emalloc(number, sizeof(int), 0);
for (i = 0; i < number; i++) {
switch (strlen (image.colorTable[i].c_color)) {

View File

@@ -12,6 +12,9 @@ require_once('skipifconnectfailure.inc');
/*** test mysqli_connect 127.0.0.1 ***/
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($mysql, "SET sql_mode=''"))
printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
$mysql->query("DROP TABLE IF EXISTS test_warnings");
$mysql->query("CREATE TABLE test_warnings (a int not null) ENGINE=myisam");

View File

@@ -0,0 +1,120 @@
--TEST--
Multiple result set with PS
--SKIPIF--
<?php
require_once('skipif.inc');
require_once("connect.inc");
if (!$IS_MYSQLND) {
die("skip mysqlnd only test");
}
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once("connect.inc");
require('table.inc');
$stmt = mysqli_stmt_init($link);
if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
printf("[001] [%d] %s\n", $link->error, $link->errno);
}
if (!$link->query("CREATE PROCEDURE p123() BEGIN SELECT id+12, CONCAT_WS('-',label,'ahoi') FROM test ORDER BY id LIMIT 1; SELECT id + 42, CONCAT_WS('---',label, label) FROM test ORDER BY id LIMIT 1; END")) {
printf("[002] [%d] %s\n", $link->error, $link->errno);
}
if (!($stmt = $link->prepare("CALL p123"))) {
printf("[003] [%d] %s\n", $stmt->error, $stmt->errno);
}
if (!$stmt->execute()) {
printf("[005] [%d] %s\n", $stmt->error, $stmt->errno);
}
$c_id = NULL;
$c_label = NULL;
if (!$stmt->bind_result($c_id, $c_label)) {
printf("[004] [%d] %s\n", $stmt->error, $stmt->errno);
}
var_dump("pre:",$c_id, $c_label);
if (!$stmt->fetch()) {
printf("[006] [%d] %s\n", $stmt->error, $stmt->errno);
}
var_dump("post:",$c_id, $c_label);
if ($stmt->fetch()) {
printf("[007] Shouldn't have fetched anything\n");
var_dump($c_id, $c_label);
}
if ($stmt->fetch()) {
printf("[008] No more rows expected\n");
}
if (!$stmt->more_results()) {
printf("[009] Expected more results\n");
} else {
var_dump("[009] next_result:", $stmt->next_result());
}
if (!$stmt->bind_result($c_id, $c_label)) {
printf("[010] [%d] %s\n", $stmt->error, $stmt->errno);
}
var_dump("pre:",$c_id, $c_label);
if (!$stmt->fetch()) {
printf("[011] [%d] %s\n", $stmt->error, $stmt->errno);
}
var_dump("post:",$c_id, $c_label);
if ($stmt->fetch()) {
printf("[012] No more rows expected\n");
}
if (!$stmt->more_results()) {
printf("[013] Expected more results\n");
} else {
var_dump("[013] next_result:", $stmt->next_result());
}
if ($stmt->more_results()) {
printf("[014] No more results expected\n");
} else {
printf("[014] No result, as expected\n");
}
$stmt->close();
$link->close();
echo "done";
?>
--CLEAN--
<?php
require_once("connect.inc");
if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
printf("[001] [%d] %s\n", $link->error, $link->errno);
}
?>
--EXPECTF--
string(4) "pre:"
NULL
NULL
string(5) "post:"
int(13)
string(6) "a-ahoi"
string(18) "[009] next_result:"
bool(true)
string(4) "pre:"
int(13)
string(6) "a-ahoi"
string(5) "post:"
int(43)
string(5) "a---a"
string(18) "[013] next_result:"
bool(true)
[014] No result, as expected
done

View File

@@ -50,6 +50,7 @@ enum_func_status mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param,
static void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt TSRMLS_DC);
static void mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
static void MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(MYSQLND_STMT * const s TSRMLS_DC);
/* {{{ mysqlnd_stmt::store_result */
static MYSQLND_RES *
@@ -226,7 +227,7 @@ MYSQLND_METHOD(mysqlnd_stmt, next_result)(MYSQLND_STMT * s TSRMLS_DC)
DBG_INF_FMT("server_status=%u cursor=%u", stmt->upsert_status->server_status, stmt->upsert_status->server_status & SERVER_STATUS_CURSOR_EXISTS);
/* Free space for next result */
s->m->free_stmt_content(s TSRMLS_CC);
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(s TSRMLS_CC);
{
enum_func_status ret = s->m->parse_execute_response(s TSRMLS_CC);
DBG_RETURN(ret);
@@ -2061,6 +2062,37 @@ mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const s, unsigned int param
/* }}} */
/* {{{ mysqlnd_stmt::free_stmt_result */
static void
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(MYSQLND_STMT * const s TSRMLS_DC)
{
MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
DBG_ENTER("mysqlnd_stmt::free_stmt_result");
if (!stmt) {
DBG_VOID_RETURN;
}
/*
First separate the bound variables, which point to the result set, then
destroy the set.
*/
mysqlnd_stmt_separate_result_bind(s TSRMLS_CC);
/* Not every statement has a result set attached */
if (stmt->result) {
stmt->result->m.free_result_internal(stmt->result TSRMLS_CC);
stmt->result = NULL;
}
if (stmt->error_info->error_list) {
zend_llist_clean(stmt->error_info->error_list);
mnd_pefree(stmt->error_info->error_list, s->persistent);
stmt->error_info->error_list = NULL;
}
DBG_VOID_RETURN;
}
/* }}} */
/* {{{ mysqlnd_stmt::free_stmt_content */
static void
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_content)(MYSQLND_STMT * const s TSRMLS_DC)
@@ -2093,22 +2125,7 @@ MYSQLND_METHOD(mysqlnd_stmt, free_stmt_content)(MYSQLND_STMT * const s TSRMLS_DC
stmt->param_bind = NULL;
}
/*
First separate the bound variables, which point to the result set, then
destroy the set.
*/
mysqlnd_stmt_separate_result_bind(s TSRMLS_CC);
/* Not every statement has a result set attached */
if (stmt->result) {
stmt->result->m.free_result_internal(stmt->result TSRMLS_CC);
stmt->result = NULL;
}
if (stmt->error_info->error_list) {
zend_llist_clean(stmt->error_info->error_list);
mnd_pefree(stmt->error_info->error_list, s->persistent);
stmt->error_info->error_list = NULL;
}
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(s TSRMLS_CC);
DBG_VOID_RETURN;
}
/* }}} */

View File

@@ -226,7 +226,7 @@ php_mysqlnd_net_store_length_size(uint64_t length)
if (length < (uint64_t) L64(16777216)) {
return 4;
}
return 8;
return 9;
}
/* }}} */

View File

@@ -780,6 +780,9 @@ PHP_MINIT_FUNCTION(odbc)
REGISTER_LONG_CONSTANT("SQL_TYPE_DATE", SQL_TYPE_DATE, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_TYPE_TIME", SQL_TYPE_TIME, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_TYPE_TIMESTAMP", SQL_TYPE_TIMESTAMP, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WCHAR", SQL_WCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WVARCHAR", SQL_WVARCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WLONGVARCHAR", SQL_WLONGVARCHAR, CONST_PERSISTENT | CONST_CS);
/*
* SQLSpecialColumns values
@@ -943,9 +946,13 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
{
RETCODE rc;
int i;
SQLSMALLINT colnamelen; /* Not used */
SQLLEN displaysize;
SQLSMALLINT colnamelen; /* Not used */
SQLLEN displaysize;
SQLUSMALLINT colfieldid;
int charextraalloc;
colfieldid = SQL_COLUMN_DISPLAY_SIZE;
charextraalloc = 0;
result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
result->longreadlen = ODBCG(defaultlrl);
@@ -966,6 +973,9 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
result->values[i].value = NULL;
break;
@@ -976,15 +986,27 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
27, &result->values[i].vallen);
break;
#endif /* HAVE_ADABAS */
case SQL_CHAR:
case SQL_VARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WCHAR:
case SQL_WVARCHAR:
colfieldid = SQL_DESC_OCTET_LENGTH;
#else
charextraalloc = 1;
#endif
default:
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_DISPLAY_SIZE,
NULL, 0, NULL, &displaysize);
displaysize = displaysize <= result->longreadlen ? displaysize :
result->longreadlen;
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), colfieldid,
NULL, 0, NULL, &displaysize);
/* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */
if (result->values[i].coltype == SQL_TIMESTAMP) {
displaysize += 3;
}
if (charextraalloc) {
/* Since we don't know the exact # of bytes, allocate extra */
displaysize *= 4;
}
result->values[i].value = (char *)emalloc(displaysize + 1);
rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
displaysize + 1, &result->values[i].vallen);
@@ -1725,6 +1747,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
sql_c_type = SQL_C_BINARY;
}
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
@@ -1876,7 +1901,11 @@ PHP_FUNCTION(odbc_fetch_into)
break;
}
if (result->binmode == 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
@@ -2095,6 +2124,9 @@ PHP_FUNCTION(odbc_result)
break;
}
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[field_ind].coltype)) {
if (result->longreadlen <= 0) {
break;
@@ -2132,7 +2164,11 @@ PHP_FUNCTION(odbc_result)
}
/* Reduce fieldlen by 1 if we have char data. One day we might
have binary strings... */
if (result->values[field_ind].coltype == SQL_LONGVARCHAR) {
if ((result->values[field_ind].coltype == SQL_LONGVARCHAR)
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
|| (result->values[field_ind].coltype == SQL_WLONGVARCHAR)
#endif
) {
fieldsize -= 1;
}
/* Don't duplicate result, saves one emalloc.
@@ -2248,6 +2284,9 @@ PHP_FUNCTION(odbc_result_all)
}
if (result->binmode <= 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) &&
result->longreadlen <= 0) {
php_printf("<td>Not printable</td>");

View File

@@ -115,6 +115,7 @@ PHP_FUNCTION(solid_fetch_prev);
#endif
#define ODBC_TYPE "unixODBC"
#undef ODBCVER
#include <sql.h>
#include <sqlext.h>
#define HAVE_SQL_EXTENDED_FETCH 1
@@ -284,7 +285,11 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC);
void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WLONGVARCHAR)
#else
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
#endif
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
#ifdef ZTS

View File

@@ -0,0 +1,69 @@
--TEST--
odbc_exec(): Getting accurate unicode data from query
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
// Test strings
mb_internal_encoding("EUC_JP");
$euc_jp_base64 = 'pdal6aWkpcCl676uyqo=';
$euc_jp = base64_decode($euc_jp_base64);
$ascii = 'abcdefghijklmnopqrstuvwxyz;]=#0123456789';
include 'config.inc';
ini_set("odbc.defaultlrl", 4); // Set artifically low
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'CREATE DATABASE odbcTEST ENCODING=\'EUC_JP\'');
odbc_exec($conn, 'CREATE TABLE FOO (ID INT, CHAR_COL CHAR(200), VARCHAR_COL VARCHAR(200), TEXT_COL TEXT)');
odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (1, '$euc_jp', '$euc_jp', '$euc_jp')");
odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (2, '$ascii', '$ascii', '$ascii')");
$res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC');
while(odbc_fetch_row($res)) {
$char_col = odbc_result($res, "CHAR_COL");
$varchar_col = odbc_result($res, "VARCHAR_COL");
$id = odbc_result($res, "ID");
$text_col = "";
while (($chunk=odbc_result($res, "TEXT_COL")) !== false) {
$text_col .= $chunk;
}
if ($id == 1) {
$euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp)));
if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 &&
strcmp($text_col, $euc_jp) == 0) {
print "EUC-JP matched\n";
} else {
print "EUC-JP mismatched\n";
}
} else {
$ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii)));
if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 &&
strcmp($text_col, $ascii) == 0) {
print "ASCII matched\n";
} else {
print "ASCII mismatched\n";
}
}
}
?>
--EXPECT--
EUC-JP matched
ASCII matched
--CLEAN--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'DROP TABLE FOO');
odbc_exec($conn, 'DROP DATABASE odbcTEST');
?>

View File

@@ -24,9 +24,5 @@ resource(%d) of type (odbc result)
bool(false)
resource(%d) of type (odbc result)
bool(false)
Warning: odbc_columns(): SQL error: Failed to fetch error message, SQL state HY000 in SQLColumns in %s on line %d
resource(%d) of type (odbc result)
bool(false)
Warning: odbc_fetch_row() expects parameter 1 to be resource, boolean given in %s on line %d
NULL

View File

@@ -12,7 +12,7 @@ $conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'CREATE DATABASE odbcTEST');
odbc_exec($conn, 'CREATE TABLE FOO (TEST INT)');
odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY FOO(TEST)');
odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY (TEST)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (1)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (2)');

View File

@@ -979,7 +979,6 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
if (zend_hash_num_elements(&persistent_script->class_table) > 0) {
zend_accel_class_hash_copy(CG(class_table), &persistent_script->class_table, NULL TSRMLS_CC);
}
free_persistent_script(persistent_script, 0); /* free only hashes */
}
#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
@@ -991,6 +990,10 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
}
#endif
if (!from_shared_memory) {
free_persistent_script(persistent_script, 0); /* free only hashes */
}
return op_array;
}

View File

@@ -666,7 +666,7 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
return (time_t)-1;
}
if (ASN1_STRING_length(timestr) != strlen(ASN1_STRING_data(timestr))) {
if (ASN1_STRING_length(timestr) != strlen((char *)ASN1_STRING_data(timestr))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "illegal length in timestamp");
return (time_t)-1;
}
@@ -794,13 +794,13 @@ static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */
req->config_filename, req->var, req->req_config TSRMLS_CC) == FAILURE) return FAILURE
#define SET_OPTIONAL_STRING_ARG(key, varname, defval) \
if (optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), key, sizeof(key), (void**)&item) == SUCCESS) \
if (optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), key, sizeof(key), (void**)&item) == SUCCESS && Z_TYPE_PP(item) == IS_STRING) \
varname = Z_STRVAL_PP(item); \
else \
varname = defval
#define SET_OPTIONAL_LONG_ARG(key, varname, defval) \
if (optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), key, sizeof(key), (void**)&item) == SUCCESS) \
if (optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), key, sizeof(key), (void**)&item) == SUCCESS && Z_TYPE_PP(item) == IS_LONG) \
varname = Z_LVAL_PP(item); \
else \
varname = defval
@@ -859,7 +859,8 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
}
}
if (req->priv_key_encrypt && optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), "encrypt_key_cipher", sizeof("encrypt_key_cipher"), (void**)&item) == SUCCESS) {
if (req->priv_key_encrypt && optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), "encrypt_key_cipher", sizeof("encrypt_key_cipher"), (void**)&item) == SUCCESS
&& Z_TYPE_PP(item) == IS_LONG) {
long cipher_algo = Z_LVAL_PP(item);
const EVP_CIPHER* cipher = php_openssl_get_evp_cipher_from_algo(cipher_algo);
if (cipher == NULL) {
@@ -1974,7 +1975,7 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)
}
/* parse extra config from args array, promote this to an extra function */
if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS)
if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS && Z_TYPE_PP(item) == IS_STRING)
friendly_name = Z_STRVAL_PP(item);
/* certpbe (default RC2-40)
keypbe (default 3DES)
@@ -2052,7 +2053,7 @@ PHP_FUNCTION(openssl_pkcs12_export)
}
/* parse extra config from args array, promote this to an extra function */
if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS)
if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS && Z_TYPE_PP(item) == IS_STRING)
friendly_name = Z_STRVAL_PP(item);
if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS)

View File

@@ -0,0 +1,12 @@
--TEST--
Options type checks
--SKIPIF--
<?php if (!extension_loaded("openssl")) print "skip"; ?>
--FILE--
<?php
$x = openssl_pkey_new();
$csr = openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF]);
?>
DONE
--EXPECT--
DONE

View File

@@ -204,13 +204,59 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
return didwrite;
}
static void php_openssl_stream_wait_for_data(php_netstream_data_t *sock)
{
int retval;
struct timeval *ptimeout;
if (sock->socket == -1) {
return;
}
sock->timeout_event = 0;
if (sock->timeout.tv_sec == -1)
ptimeout = NULL;
else
ptimeout = &sock->timeout;
while(1) {
retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout);
if (retval == 0)
sock->timeout_event = 1;
if (retval >= 0)
break;
if (php_socket_errno() != EINTR)
break;
}
}
static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
php_netstream_data_t *sock;
int nr_bytes = 0;
if (sslsock->ssl_active) {
int retry = 1;
sock = (php_netstream_data_t*)stream->abstract;
/* The SSL_read() function will block indefinitely waiting for data on a blocking
socket. If we don't poll for readability first this operation has the potential
to hang forever. To avoid this scenario we poll with a timeout before performing
the actual read. If it times out we're finished.
*/
if (sock->is_blocked) {
php_openssl_stream_wait_for_data(sock);
if (sock->timeout_event) {
stream->eof = 1;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL read operation timed out");
return nr_bytes;
}
}
do {
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);

View File

@@ -99,6 +99,9 @@ static size_t readline_shell_write(const char *str, uint str_length TSRMLS_DC) /
static int readline_shell_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
{
/* We just store the last char here and then pass back to the
caller (sapi_cli_single_write in sapi/cli) which will actually
write due to -1 return code */
php_last_char = str[str_length-1];
return -1;
}
@@ -587,6 +590,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
char *code = emalloc(size);
char *prompt = cli_get_prompt("php", '>' TSRMLS_CC);
char *history_file;
int history_lines_to_write = 0;
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
zend_file_handle *prepend_file_p;
@@ -651,6 +655,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
if (*line) {
add_history(line);
history_lines_to_write += 1;
}
free(line);
@@ -660,6 +665,15 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
continue;
}
if (history_lines_to_write) {
#if HAVE_LIBEDIT
write_history(history_file);
#else
append_history(history_lines_to_write, history_file);
#endif
history_lines_to_write = 0;
}
zend_try {
zend_eval_stringl(code, pos, NULL, "php shell code" TSRMLS_CC);
} zend_end_try();
@@ -667,7 +681,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
pos = 0;
if (!pager_pipe && php_last_char != '\0' && php_last_char != '\n') {
readline_shell_write("\n", 1 TSRMLS_CC);
php_write("\n", 1 TSRMLS_CC);
}
if (EG(exception)) {
@@ -681,7 +695,6 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
php_last_char = '\0';
}
write_history(history_file);
free(history_file);
efree(code);
efree(prompt);

View File

@@ -301,7 +301,8 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &array) == SUCCESS &&
Z_TYPE_PP(array) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(array), "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &token) == SUCCESS
zend_hash_find(Z_ARRVAL_PP(array), "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &token) == SUCCESS &&
Z_TYPE_PP(token) == IS_STRING
) {
remote_addr = Z_STRVAL_PP(token);
}
@@ -1422,9 +1423,16 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{
}
/* }}} */
#define PPID2SID \
convert_to_string((*ppid)); \
PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid))
static void ppid2sid(zval **ppid TSRMLS_DC) {
if (Z_TYPE_PP(ppid) != IS_STRING) {
PS(id) = NULL;
PS(send_cookie) = 1;
} else {
convert_to_string((*ppid));
PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid));
PS(send_cookie) = 0;
}
}
PHPAPI void php_session_reset_id(TSRMLS_D) /* {{{ */
{
@@ -1518,9 +1526,8 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
Z_TYPE_PP(data) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
) {
PPID2SID;
ppid2sid(ppid TSRMLS_CC);
PS(apply_trans_sid) = 0;
PS(send_cookie) = 0;
PS(define_sid) = 0;
}
@@ -1529,8 +1536,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
Z_TYPE_PP(data) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
) {
PPID2SID;
PS(send_cookie) = 0;
ppid2sid(ppid TSRMLS_CC);
}
if (!PS(use_only_cookies) && !PS(id) &&
@@ -1538,8 +1544,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
Z_TYPE_PP(data) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
) {
PPID2SID;
PS(send_cookie) = 0;
ppid2sid(ppid TSRMLS_CC);
}
}

View File

@@ -0,0 +1,12 @@
--TEST--
Bug #66827: Session raises E_NOTICE when session name variable is array.
--INI--
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$_COOKIE[session_name()] = array();
session_start();
echo 'OK';
--EXPECTF--
OK

View File

@@ -1985,7 +1985,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
if (should_rehash) {
zend_hash_rehash(Z_ARRVAL_P(stack));
}
} else if (!key_len && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
} else if (!key_len && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1;
}

View File

@@ -592,6 +592,14 @@ PHPAPI char *php_get_uname(char mode)
php_get_windows_cpu(wincpu, sizeof(wincpu));
dwBuild = (DWORD)(HIWORD(dwVersion));
/* Windows "version" 6.2 could be Windows 8/Windows Server 2012, but also Windows 8.1/Windows Server 2012 R2 */
if (dwWindowsMajorVersion == 6 && dwWindowsMinorVersion == 2) {
if (strncmp(winver, "Windows 8.1", 11) == 0 || strncmp(winver, "Windows Server 2012 R2", 22) == 0) {
dwWindowsMinorVersion = 3;
}
}
snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d build %d (%s) %s",
"Windows NT", ComputerName,
dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild, winver?winver:"unknown", wincpu);

View File

@@ -0,0 +1,25 @@
--TEST--
Bug #67693 - incorrect push to empty array
--FILE--
<?php
$array = array(-1 => 0);
array_pop($array);
array_push($array, 0);
array_push($array, 0);
var_dump($array);
echo"\nDone";
?>
--EXPECT--
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
Done

Binary file not shown.

View File

@@ -0,0 +1,26 @@
--TEST--
Bug #67724 (chained zlib filters silently fail with large amounts of data)
--SKIPIF--
<?php
extension_loaded("zlib") or die("skip need ext/zlib");
?>
--FILE--
<?php
echo "Test\n";
$f = fopen(__DIR__."/bug67724.gz.gz", "rb")
or die(current(error_get_last()));
stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]);
stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]);
for ($i = 0; !feof($f); $i += strlen(fread($f, 0x1000)))
;
fclose($f);
var_dump($i);
?>
DONE
--EXPECT--
Test
int(25600000)
DONE

View File

@@ -302,7 +302,8 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
data->strm.zalloc = (alloc_func) php_zlib_alloc;
data->strm.zfree = (free_func) php_zlib_free;
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
data->strm.avail_out = data->outbuf_len = 0x8000;
data->inbuf_len = 2048;
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
if (!data->inbuf) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len);

View File

@@ -2,7 +2,7 @@
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 5
#define PHP_RELEASE_VERSION 15
#define PHP_RELEASE_VERSION 17
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.5.15-dev"
#define PHP_VERSION_ID 50515
#define PHP_VERSION "5.5.17-dev"
#define PHP_VERSION_ID 50517

View File

@@ -567,14 +567,41 @@ if test "$PHP_FPM" != "no"; then
[ --with-fpm-systemd Activate systemd integration], no, no)
if test "$PHP_FPM_SYSTEMD" != "no" ; then
AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon")
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
unset SYSTEMD_LIBS
unset SYSTEMD_INCS
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd; then
dnl systemd version >= 209 provides libsystemd
AC_MSG_CHECKING([for libsystemd])
SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd`
SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd`
SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd`
AC_MSG_RESULT([version $SYSTEMD_VERS])
elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd-daemon; then
dnl systemd version < 209 provides libsystemd-daemon
AC_MSG_CHECKING([for libsystemd-daemon])
SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd-daemon`
SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd-daemon`
SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd-daemon`
AC_MSG_RESULT([version $SYSTEMD_VERS])
else
dnl failback when no pkg-config
AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon")
fi
AC_CHECK_HEADERS(systemd/sd-daemon.h, [HAVE_SD_DAEMON_H="yes"], [HAVE_SD_DAEMON_H="no"])
if test $HAVE_SD_DAEMON_H = "no" || test -z "${SYSTEMD_LIBS}"; then
AC_MSG_ERROR([Your system does not support systemd.])
else
AC_DEFINE(HAVE_SYSTEMD, 1, [FPM use systemd integration])
PHP_FPM_SD_FILES="fpm/fpm_systemd.c"
PHP_ADD_LIBRARY(systemd-daemon)
PHP_EVAL_LIBLINE($SYSTEMD_LIBS)
PHP_EVAL_INCLINE($SYSTEMD_INCS)
php_fpm_systemd=notify
fi
else

View File

@@ -1,8 +1,8 @@
milter: $(SAPI_MILTER_PATH)
$(SAPI_MILTER_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_SAPI_OBJS)
$(SAPI_MILTER_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MILTER_OBJS)
$(BUILD_MILTER)
install-milter: $(SAPI_MILTER_PATH)
@$(INSTALL) -m 0755 $(SAPI_MILTER_PATH) $(bindir)/php-milter
@$(INSTALL) -m 0755 $(SAPI_MILTER_PATH) $(INSTALL_ROOT)$(bindir)/php-milter

View File

@@ -22,10 +22,10 @@ if test "$PHP_MILTER" != "no"; then
SAPI_MILTER_PATH=sapi/milter/php-milter
PHP_BUILD_THREAD_SAFE
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/milter/Makefile.frag)
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/milter/Makefile.frag,$abs_srcdir/sapi/milter,sapi/milter)
PHP_SELECT_SAPI(milter, program, php_milter.c getopt.c,,'$(SAPI_MILTER_PATH)')
PHP_ADD_LIBRARY_WITH_PATH(milter, $MILTERPATH,)
BUILD_MILTER="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_MILTER_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_MILTER_PATH)"
BUILD_MILTER="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_MILTER_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_MILTER_PATH)"
PHP_SUBST(SAPI_MILTER_PATH)
PHP_SUBST(BUILD_MILTER)
fi

View File

@@ -525,6 +525,10 @@ static sfsistat mlfi_close(SMFICTX *ctx)
int status;
TSRMLS_FETCH();
if (!SG(sapi_started) && SUCCESS != php_request_startup(TSRMLS_C)) {
return ret;
}
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_close", 0);
@@ -550,7 +554,7 @@ static sfsistat mlfi_close(SMFICTX *ctx)
/* {{{ Milter entry struct
*/
struct smfiDesc smfilter = {
static struct smfiDesc smfilter = {
"php-milter", /* filter name */
SMFI_VERSION, /* version code -- leave untouched */
0, /* flags */
@@ -1015,6 +1019,7 @@ int main(int argc, char *argv[])
tsrm_startup(1, 1, 0, NULL);
tsrm_ls = ts_resource(0);
sapi_startup(&milter_sapi_module);
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
@@ -1032,7 +1037,6 @@ int main(int argc, char *argv[])
milter_sapi_module.executable_location = argv[0];
tsrm_ls = ts_resource(0);
sapi_module.startup(&milter_sapi_module);

View File

@@ -183,7 +183,7 @@ msi-installer: dist
# need to redirect, since INSTALL is a file in the root...
install: really-install install-sdk
build-lib:
build-lib: build-ext-libs
@if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul
@copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul

View File

@@ -105,6 +105,11 @@ if (PHP_DEBUG == "yes" && PHP_DEBUG_PACK == "yes") {
ERROR("Use of both --enable-debug and --enable-debug-pack not allowed.");
}
if (PHP_PREFIX == '') {
PHP_PREFIX = "C:\\php";
if (PHP_DEBUG == "yes")
PHP_PREFIX += "\\debug";
}
DEFINE('PHP_PREFIX', PHP_PREFIX);
DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/main /I " + PHP_DIR + "/include/Zend /I " + PHP_DIR + "/include/TSRM /I " + PHP_DIR + "/include/ext ");

View File

@@ -1362,9 +1362,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) {
cflags = "/FI main/config.pickle.h " + cflags;
}
if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) {
cflags = "/FI main/config.pickle.h " + cflags;
}
ADD_FLAG("CFLAGS_" + EXT, cflags);
if (PHP_DSP != "no") {
@@ -1884,6 +1881,7 @@ function generate_phpize()
var MF = FSO.CreateTextFile(dest + "/phpize.js", true);
var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true);
prefix = get_define("PHP_PREFIX");
prefix = prefix.replace(new RegExp("/", "g"), "\\");
prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\");
@@ -1969,8 +1967,21 @@ function generate_makefile()
for (var i in extensions_enabled) {
var lib = "php_" + extensions_enabled[i][0] + ".lib";
var dll = "php_" + extensions_enabled[i][0] + ".dll";
MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib\\" + lib);
//MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)\\" + dll);
MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)");
}
} else {
MF.WriteBlankLines(1);
MF.WriteLine("build-ext-libs:");
MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\lib mkdir $(BUILD_DIR_DEV)\\lib >nul");
for (var i in extensions_enabled) {
var lib;
lib = "php_" + extensions_enabled[i][0] + "*.lib";
if ('shared' == extensions_enabled[i][1]) {
MF.WriteLine(" @if exist $(BUILD_DIR)\\" + lib + " copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
}
}
}
TF.Close();

View File

@@ -40,9 +40,13 @@ function ERROR(msg)
function file_get_contents(filename)
{
var t = "";
var F = FSO.OpenTextFile(filename, 1);
var t = F.ReadAll();
F.Close();
if (!F.AtEndOfStream) {
t = F.ReadAll();
F.Close();
}
return t;
}

View File

@@ -66,8 +66,12 @@
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
#ifndef int8_t
typedef __int8 int8_t;
#endif
#ifndef int16_t
typedef __int16 int16_t;
#endif
#ifndef int32_t
typedef __int32 int32_t;
#endif