diff options
author | Anatol Belski <ab@php.net> | 2014-10-16 13:49:35 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-10-16 13:49:35 +0200 |
commit | 69fa6523e89c4731b576a46921fd30f0aad7734e (patch) | |
tree | a389c99a119b5cf1930682ab340266f07354d7bb | |
parent | 7f1107de9167ab1443a13491f5b70aa3f10fd323 (diff) | |
parent | 53a8584123f359c2c32f1869d98e4dd9e0a7a6ab (diff) | |
download | php-git-69fa6523e89c4731b576a46921fd30f0aad7734e.tar.gz |
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master:
Fix allocator for 64bit zend_long with 32bit long
Use intptr_t for zend_intptr_t typedef
Fix format strings in zend_alloc
Drop zend_long64 in favor of int64_t
Removed deprecated fields
NEWS
cleanup NEWS
removing the NEWS entry as we had to revert this fix for now
Revert "Merge branch 'PHP-5.5' into PHP-5.6"
Revert "fix TS build"
Revert "Merge branch 'PHP-5.4' into PHP-5.5"
Revert "Bug #67965: Fix blocking behavior in non-blocking crypto streams"
Revert "Bug #41631: Fix regression from first attempt (6569db8)"
NEWS
Fixed Bug #65171 imagescale() fails
Fixed bug #68234
Fixed bug #68215 (Behavior of foreach has changed)
Revert "Bug #41631: Observe socket read timeouts in SSL streams"
PHP-5.6.3 is next
update NEWS, 5.6.2 will be a security-only release
-rw-r--r-- | Zend/tests/bug68215.phpt | 91 | ||||
-rw-r--r-- | Zend/zend_alloc.c | 28 | ||||
-rw-r--r-- | Zend/zend_compile.h | 2 | ||||
-rw-r--r-- | Zend/zend_hash.h | 7 | ||||
-rw-r--r-- | Zend/zend_multiply.h | 12 | ||||
-rw-r--r-- | Zend/zend_types.h | 24 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 17 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 20 | ||||
-rw-r--r-- | ext/gd/gd.c | 16 | ||||
-rw-r--r-- | ext/openssl/tests/bug65729.pem | 56 | ||||
-rw-r--r-- | ext/openssl/xp_ssl.c | 61 | ||||
-rw-r--r-- | main/php_streams.h | 3 | ||||
-rw-r--r-- | main/streams/streams.c | 8 |
13 files changed, 198 insertions, 147 deletions
diff --git a/Zend/tests/bug68215.phpt b/Zend/tests/bug68215.phpt new file mode 100644 index 0000000000..c4e8da8515 --- /dev/null +++ b/Zend/tests/bug68215.phpt @@ -0,0 +1,91 @@ +--TEST-- +Bug #68215 (Behavior of foreach has changed) +--FILE-- +<?php +$arr = array( + 'a' => array( + 'a' => 'apple', + 'b' => 'banana', + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' + ), + 'b' => array( + 'a' => 'apple', + 'b' => 'banana', + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' + ), + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' +); + +function test(&$child, $entry) +{ + $i = 1; + + foreach ($child AS $key => $fruit) + { + if (!is_numeric($key)) + { + $child[$i] = $fruit; + unset($child[$key]); + $i++; + } + } +} + +$i = 1; + +foreach ($arr AS $key => $fruit) +{ + $arr[$i] = $fruit; + + if (is_array($fruit)) + { + test($arr[$i], $fruit); + } + + unset($arr[$key]); + $i++; +} + +var_dump($arr); +?> +--EXPECT-- +array(5) { + [1]=> + array(5) { + [1]=> + string(5) "apple" + [2]=> + string(6) "banana" + [3]=> + string(9) "cranberry" + [4]=> + string(5) "mango" + [5]=> + string(9) "pineapple" + } + [2]=> + array(5) { + [1]=> + string(5) "apple" + [2]=> + string(6) "banana" + [3]=> + string(9) "cranberry" + [4]=> + string(5) "mango" + [5]=> + string(9) "pineapple" + } + [3]=> + string(9) "cranberry" + [4]=> + string(5) "mango" + [5]=> + string(9) "pineapple" +} diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index c647669ea7..8bc7bcb44d 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -482,7 +482,11 @@ static void zend_mm_munmap(void *addr, size_t size) static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset) { #if defined(__GNUC__) +# if SIZEOF_ZEND_LONG == SIZEOF_LONG return __builtin_ctzl(~bitset); +# else + return __builtin_ctzll(~bitset); +# endif #elif defined(_WIN32) unsigned long index; @@ -519,7 +523,11 @@ static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset) static zend_always_inline int zend_mm_bitset_ntz(zend_mm_bitset bitset) { #if defined(__GNUC__) +# if SIZEOF_ZEND_LONG == SIZEOF_LONG return __builtin_ctzl(bitset); +# else + return __builtin_ctzll(bitset); +# endif #elif defined(_WIN32) unsigned long index; @@ -962,9 +970,9 @@ not_found: if (heap->real_size + ZEND_MM_CHUNK_SIZE > heap->limit) { if (heap->overflow == 0) { #if ZEND_DEBUG - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, ZEND_MM_PAGE_SIZE * pages_count); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, ZEND_MM_PAGE_SIZE * pages_count); #endif return NULL; } @@ -976,9 +984,9 @@ not_found: #if !ZEND_MM_LIMIT zend_mm_safe_error(heap, "Out of memory"); #elif ZEND_DEBUG - zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Out of memory (allocated %zu) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, ZEND_MM_PAGE_SIZE * pages_count); + zend_mm_safe_error(heap, "Out of memory (allocated %zu) (tried to allocate %zu bytes)", heap->real_size, ZEND_MM_PAGE_SIZE * pages_count); #endif return NULL; } @@ -1415,9 +1423,9 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size ZEN if (heap->real_size + (new_size - old_size) > heap->limit) { if (heap->overflow == 0) { #if ZEND_DEBUG - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, size); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size); #endif return NULL; } @@ -1641,9 +1649,9 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D if (heap->real_size + new_size > heap->limit) { if (heap->overflow == 0) { #if ZEND_DEBUG - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted at %s:%d (tried to allocate %lu bytes)", heap->limit, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted (tried to allocate %lu bytes)", heap->limit, size); + zend_mm_safe_error(heap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size); #endif return NULL; } @@ -1655,9 +1663,9 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D #if !ZEND_MM_LIMIT zend_mm_safe_error(heap, "Out of memory"); #elif ZEND_DEBUG - zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Out of memory (allocated %zu) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, size); + zend_mm_safe_error(heap, "Out of memory (allocated %zu) (tried to allocate %zu bytes)", heap->real_size, size); #endif return NULL; } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 089c15f48a..e9ee6e56d7 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -59,11 +59,9 @@ typedef union _znode_op { uint32_t constant; uint32_t var; uint32_t num; - zend_ulong hash; uint32_t opline_num; /* Needs to be signed */ zend_op *jmp_addr; zval *zv; - void *ptr; /* Used for passing pointers from the compile to execution phase, currently used for traits */ } znode_op; typedef struct _znode { /* used only during compilation */ diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index aaa677943d..5a36ddf28f 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -170,9 +170,10 @@ ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *p ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos); typedef struct _HashPointer { - HashPosition pos; - HashTable *ht; - zend_ulong h; + HashPosition pos; + HashTable *ht; + zend_ulong h; + zend_string *key; } HashPointer; #define zend_hash_has_more_elements(ht) \ diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index 158be22007..6dce8fb6ac 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -84,10 +84,10 @@ } \ } while (0) -#elif SIZEOF_ZEND_LONG == 4 && defined(HAVE_ZEND_LONG64) +#elif SIZEOF_ZEND_LONG == 4 #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - zend_long64 __result = (zend_long64) (a) * (zend_long64) (b); \ + int64_t __result = (int64_t) (a) * (int64_t) (b); \ if (__result > ZEND_LONG_MAX || __result < ZEND_LONG_MIN) { \ (dval) = (double) __result; \ (usedval) = 1; \ @@ -117,7 +117,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) { size_t res = nmemb; - zend_ulong m_overflow = 0; + size_t m_overflow = 0; __asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1" : "=&a"(res), "=&d" (m_overflow) @@ -206,13 +206,13 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si return res; } -#elif SIZEOF_SIZE_T == 4 && defined(HAVE_ZEND_LONG64) +#elif SIZEOF_SIZE_T == 4 static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) { - zend_ulong64 res = (zend_ulong64)nmemb * (zend_ulong64)size + (zend_ulong64)offset; + uint64_t res = (uint64_t) nmemb * (uint64_t) size + (uint64_t) offset; - if (UNEXPECTED(res > (zend_ulong64)0xFFFFFFFFL)) { + if (UNEXPECTED(res > UINT64_C(0xFFFFFFFF))) { *overflow = 1; return 0; } diff --git a/Zend/zend_types.h b/Zend/zend_types.h index e3818dd2a1..383f77caa4 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -64,28 +64,8 @@ typedef enum { # endif #endif -#define HAVE_ZEND_LONG64 -#ifdef ZEND_WIN32 -typedef __int64 zend_long64; -typedef unsigned __int64 zend_ulong64; -#elif SIZEOF_LONG_LONG_INT == 8 -typedef long long int zend_long64; -typedef unsigned long long int zend_ulong64; -#elif SIZEOF_LONG_LONG == 8 -typedef long long zend_long64; -typedef unsigned long long zend_ulong64; -#else -# undef HAVE_ZEND_LONG64 -#endif - -/* XXX this won't work on X32 platform */ -#ifdef ZEND_ENABLE_ZVAL_LONG64 -typedef int64_t zend_intptr_t; -typedef uint64_t zend_uintptr_t; -#else -typedef int32_t zend_intptr_t; -typedef uint32_t zend_uintptr_t; -#endif +typedef intptr_t zend_intptr_t; +typedef uintptr_t zend_uintptr_t; typedef struct _zend_object_handlers zend_object_handlers; typedef struct _zend_class_entry zend_class_entry; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index af532e88e4..ae2f0e7161 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4576,6 +4576,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) ptr->pos = pos; ptr->ht = fe_ht; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; is_empty = 0; } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); @@ -4630,8 +4631,11 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) pos = ptr->h; } else { pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask]; - while (pos != INVALID_IDX) { - if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) { + while (1) { + if (pos == INVALID_IDX) { + pos = fe_ht->nInternalPointer; + break; + } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) { break; } pos = Z_NEXT(fe_ht->arData[pos].val); @@ -4684,6 +4688,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)); fe_ht->nInternalPointer = ptr->pos = pos; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) { @@ -4707,8 +4712,11 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) pos = ptr->h; } else { pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask]; - while (pos != INVALID_IDX) { - if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) { + while (1) { + if (pos == INVALID_IDX) { + pos = fe_ht->nInternalPointer; + break; + } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) { break; } pos = Z_NEXT(fe_ht->arData[pos].val); @@ -4777,6 +4785,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) zend_check_property_access(zobj, p->key TSRMLS_CC) == FAILURE)); fe_ht->nInternalPointer = ptr->pos = pos; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 0768aa6df2..5d448c34d4 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3222,6 +3222,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A ptr->pos = pos; ptr->ht = fe_ht; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; is_empty = 0; } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); @@ -10032,6 +10033,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG ptr->pos = pos; ptr->ht = fe_ht; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; is_empty = 0; } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); @@ -16747,6 +16749,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ptr->pos = pos; ptr->ht = fe_ht; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; is_empty = 0; } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); @@ -16801,8 +16804,11 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG pos = ptr->h; } else { pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask]; - while (pos != INVALID_IDX) { - if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) { + while (1) { + if (pos == INVALID_IDX) { + pos = fe_ht->nInternalPointer; + break; + } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) { break; } pos = Z_NEXT(fe_ht->arData[pos].val); @@ -16855,6 +16861,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)); fe_ht->nInternalPointer = ptr->pos = pos; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) { @@ -16878,8 +16885,11 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG pos = ptr->h; } else { pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask]; - while (pos != INVALID_IDX) { - if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) { + while (1) { + if (pos == INVALID_IDX) { + pos = fe_ht->nInternalPointer; + break; + } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) { break; } pos = Z_NEXT(fe_ht->arData[pos].val); @@ -16948,6 +16958,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_check_property_access(zobj, p->key TSRMLS_CC) == FAILURE)); fe_ht->nInternalPointer = ptr->pos = pos; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } else { @@ -34388,6 +34399,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS ptr->pos = pos; ptr->ht = fe_ht; ptr->h = fe_ht->arData[pos].h; + ptr->key = fe_ht->arData[pos].key; is_empty = 0; } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 54d0254c01..5a820860e6 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -5046,11 +5046,23 @@ PHP_FUNCTION(imagescale) return; } method = tmp_m; - new_width = tmp_w; - new_height = tmp_h; ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd); + if (tmp_h < 0) { + /* preserve ratio */ + long src_x, src_y; + + src_x = gdImageSX(im); + src_y = gdImageSY(im); + if (src_x) { + tmp_h = tmp_w * src_y / src_x; + } + } + + new_width = tmp_w; + new_height = tmp_h; + if (gdImageSetInterpolationMethod(im, method)) { im_scaled = gdImageScale(im, new_width, new_height); } diff --git a/ext/openssl/tests/bug65729.pem b/ext/openssl/tests/bug65729.pem index f0d44a4c78..918445712e 100644 --- a/ext/openssl/tests/bug65729.pem +++ b/ext/openssl/tests/bug65729.pem @@ -1,28 +1,32 @@ ------BEGIN CERTIFICATE----- -MIICCTCCAXICCQCx2JwIhbRefzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJT -RzESMBAGA1UECBMJVGVzdHZpbGxlMREwDwYDVQQKEwhkYXRpYmJhdzETMBEGA1UE -AxQKKi50ZXN0LmNvbTAeFw0xNDA5MjQxMTMzNTRaFw0yNDA5MjExMTMzNTRaMEkx -CzAJBgNVBAYTAlNHMRIwEAYDVQQIEwlUZXN0dmlsbGUxETAPBgNVBAoTCGRhdGli -YmF3MRMwEQYDVQQDFAoqLnRlc3QuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB -iQKBgQDBnR8DYzsN90kISI87kBvw40TQknS7/fuymWCmSrtRQLED8p2QL8PiYCZ8 -UdcFVsv+di7MJvUOzW6dRo2DCu8Rojx3ML8dAtPsQkDdaCXDnO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Rlc3QuY29tMB4XDTE0MTAxNTEzMDg1OFoXDTM0MTAxMDEzMDg1 +OFowSTELMAkGA1UEBhMCU0cxEjAQBgNVBAgTCVRlc3R2aWxsZTERMA8GA1UEChMI +ZGF0aWJiYXcxEzARBgNVBAMUCioudGVzdC5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD +gY0AMIGJAoGBANTxGAHw7a5HcCmOXERfmukIj6AhpneHREEAX2s0D+zSk9O1f940 +YmAPK5P9MXqZy/Qj/T+zZZKYgTnQ1bq2BZntGgF1XD8yIHI+3q8rVoOuCBvJw38L +pGvGsSx1l7cT0INkIUzVuvz/y2dXX0m7zSDzNjYyAOMCNKR5c3nKneSBAgMBAAGj +gaswgagwHQYDVR0OBBYEFErHO0eHLp9YvBWVvvhty/jGie5wMHkGA1UdIwRyMHCA +FErHO0eHLp9YvBWVvvhty/jGie5woU2kSzBJMQswCQYDVQQGEwJTRzESMBAGA1UE +CBMJVGVzdHZpbGxlMREwDwYDVQQKEwhkYXRpYmJhdzETMBEGA1UEAxQKKi50ZXN0 +LmNvbYIJANOyJnvPEioVMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEA +gMv2HUUp0FMTYQ6tL9YgNUNARukxJzGDWweo4/YuNSgI+Ljpye4Nf1MpyDWfhZGc +QbUhfm5CdEvcBzZBtI0lLXs61yGdLnDH/6QHViXP2rlH0yeAABw8+wSdxuiZN1yR +ed4pNXU+tczgW2Ri2+T0ScOZd0XommKHrQnu2T9mMBY= +-----END CERTIFICATE----- diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 54562c22e5..df2b6dd58e 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -1778,59 +1778,13 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size } /* }}} */ -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 && SSL_pending(sslsock->ssl_handle) == 0) { - 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); @@ -2149,21 +2103,6 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS case PHP_STREAM_AS_FD_FOR_SELECT: if (ret) { - /* OpenSSL has an internal buffer which select() cannot see. If we don't - * fetch it into the stream's buffer, no activity will be reported on the - * stream even though there is data waiting to be read - but we only fetch - * the lower of bytes OpenSSL has ready to give us or chunk_size since we - * weren't asked for any data at this stage. This is only likely to cause - * issues with non-blocking streams, but it's harmless to always do it. */ - size_t pending; - if (stream->writepos == stream->readpos - && sslsock->ssl_active - && (pending = (size_t)SSL_pending(sslsock->ssl_handle)) > 0) { - php_stream_fill_read_buffer(stream, pending < stream->chunk_size - ? pending - : stream->chunk_size); - } - *(php_socket_t *)ret = sslsock->s.socket; } return SUCCESS; diff --git a/main/php_streams.h b/main/php_streams.h index 34d7676f09..77a2234d92 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -295,9 +295,6 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun #define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str) TSRMLS_CC) #define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count) TSRMLS_CC) -PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC); -#define php_stream_fill_read_buffer(stream, size) _php_stream_fill_read_buffer((stream), (size) TSRMLS_CC) - #ifdef ZTS PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); #else diff --git a/main/streams/streams.c b/main/streams/streams.c index bc84d52655..6be2b91dc7 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -572,7 +572,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov /* {{{ generic stream operations */ -PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC) +static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC) { /* allocate/fill the buffer */ @@ -740,7 +740,7 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS break; } } else { - php_stream_fill_read_buffer(stream, size); + php_stream_fill_read_buffer(stream, size TSRMLS_CC); toread = stream->writepos - stream->readpos; if (toread > size) { @@ -976,7 +976,7 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, } } - php_stream_fill_read_buffer(stream, toread); + php_stream_fill_read_buffer(stream, toread TSRMLS_CC); if (stream->writepos - stream->readpos == 0) { break; @@ -1051,7 +1051,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con to_read_now = MIN(maxlen - buffered_len, stream->chunk_size); - php_stream_fill_read_buffer(stream, buffered_len + to_read_now); + php_stream_fill_read_buffer(stream, buffered_len + to_read_now TSRMLS_CC); just_read = STREAM_BUFFERED_AMOUNT(stream) - buffered_len; |