Created
February 2, 2018 13:09
-
-
Save robinmulder/916a7b5f059870d1348e4b5423a2ef7e to your computer and use it in GitHub Desktop.
Patch for PHP bug 52752
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -crB php-5.6.33/Zend/zend_language_scanner.c php-5.6.33-patched/Zend/zend_language_scanner.c | |
*** php-5.6.33/Zend/zend_language_scanner.c 2018-01-03 00:41:52.000000000 +0100 | |
--- php-5.6.33-patched/Zend/zend_language_scanner.c 2018-02-02 13:26:46.136423102 +0100 | |
*************** | |
*** 38,43 **** | |
--- 38,46 ---- | |
#ifdef PHP_WIN32 | |
# include <Winuser.h> | |
#endif | |
+ #ifndef _WIN32 | |
+ # include "zend_signal.h" | |
+ #endif | |
#include "zend_alloc.h" | |
#include <zend_language_parser.h> | |
#include "zend_compile.h" | |
*************** | |
*** 125,130 **** | |
--- 128,141 ---- | |
BEGIN_EXTERN_C() | |
+ #ifndef _WIN32 | |
+ static sigjmp_buf sigbus_jmpbuf; | |
+ static void sigbus_handler (int sig, siginfo_t *siginfo, void *ptr) | |
+ { | |
+ siglongjmp(sigbus_jmpbuf, 1); | |
+ } | |
+ #endif | |
+ | |
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) | |
{ | |
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); | |
*************** | |
*** 580,585 **** | |
--- 591,620 ---- | |
} | |
compilation_successful=0; | |
} else { | |
+ #ifndef _WIN32 | |
+ struct sigaction sigbus_signal; | |
+ struct sigaction old_sigbus_signal; | |
+ | |
+ memset(&sigbus_signal, 0, sizeof(sigbus_signal)); | |
+ memset(&old_sigbus_signal, 0, sizeof(old_sigbus_signal)); | |
+ sigbus_signal.sa_sigaction = sigbus_handler; | |
+ sigbus_signal.sa_flags = SA_SIGINFO; | |
+ #endif | |
+ | |
+ #if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal TSRMLS_CC); } zend_end_try(); | |
+ #elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal); | |
+ #endif | |
+ | |
+ #ifndef _WIN32 | |
+ if (sigsetjmp(sigbus_jmpbuf, 1)) { | |
+ if (file_handle->type != ZEND_HANDLE_STREAM) { | |
+ file_handle->type = ZEND_HANDLE_STREAM; | |
+ } | |
+ } | |
+ #endif | |
+ | |
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); | |
CG(in_compilation) = 1; | |
CG(active_op_array) = op_array; | |
*************** | |
*** 592,597 **** | |
--- 627,638 ---- | |
zend_bailout(); | |
} | |
compilation_successful=1; | |
+ | |
+ #if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &old_sigbus_signal, 0 TSRMLS_CC); } zend_end_try(); | |
+ #elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &old_sigbus_signal, 0); | |
+ #endif | |
} | |
if (retval) { | |
diff -crB php-5.6.33/Zend/zend_language_scanner.l php-5.6.33-patched/Zend/zend_language_scanner.l | |
*** php-5.6.33/Zend/zend_language_scanner.l 2018-01-03 00:41:52.000000000 +0100 | |
--- php-5.6.33-patched/Zend/zend_language_scanner.l 2018-02-02 13:28:58.917978606 +0100 | |
*************** | |
*** 36,41 **** | |
--- 36,44 ---- | |
#ifdef PHP_WIN32 | |
# include <Winuser.h> | |
#endif | |
+ #ifndef _WIN32 | |
+ # include "zend_signal.h" | |
+ #endif | |
#include "zend_alloc.h" | |
#include <zend_language_parser.h> | |
#include "zend_compile.h" | |
*************** | |
*** 123,128 **** | |
--- 126,139 ---- | |
BEGIN_EXTERN_C() | |
+ #ifndef _WIN32 | |
+ static sigjmp_buf sigbus_jmpbuf; | |
+ static void sigbus_handler (int sig, siginfo_t *siginfo, void *ptr) | |
+ { | |
+ siglongjmp(sigbus_jmpbuf, 1); | |
+ } | |
+ #endif | |
+ | |
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) | |
{ | |
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); | |
*************** | |
*** 578,583 **** | |
--- 589,618 ---- | |
} | |
compilation_successful=0; | |
} else { | |
+ #ifndef _WIN32 | |
+ struct sigaction sigbus_signal; | |
+ struct sigaction old_sigbus_signal; | |
+ | |
+ memset(&sigbus_signal, 0, sizeof(sigbus_signal)); | |
+ memset(&old_sigbus_signal, 0, sizeof(old_sigbus_signal)); | |
+ sigbus_signal.sa_sigaction = sigbus_handler; | |
+ sigbus_signal.sa_flags = SA_SIGINFO; | |
+ #endif | |
+ | |
+ #if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal TSRMLS_CC); } zend_end_try(); | |
+ #elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal); | |
+ #endif | |
+ | |
+ #ifndef _WIN32 | |
+ if (sigsetjmp(sigbus_jmpbuf, 1)) { | |
+ if (file_handle->type != ZEND_HANDLE_STREAM) { | |
+ file_handle->type = ZEND_HANDLE_STREAM; | |
+ } | |
+ } | |
+ #endif | |
+ | |
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); | |
CG(in_compilation) = 1; | |
CG(active_op_array) = op_array; | |
*************** | |
*** 590,595 **** | |
--- 625,636 ---- | |
zend_bailout(); | |
} | |
compilation_successful=1; | |
+ | |
+ #if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &old_sigbus_signal, 0 TSRMLS_CC); } zend_end_try(); | |
+ #elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &old_sigbus_signal, 0); | |
+ #endif | |
} | |
if (retval) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment