From f8cdf962a3499e3cb722992048cf7cf2dc09bde9 Mon Sep 17 00:00:00 2001 From: pk1234 Date: Sun, 29 Aug 2021 11:36:20 +0200 Subject: [PATCH 1/4] fix ora-03131 on bigendian 64bit machines out-variables cannot be used on bigendian 64bit machines and cause ORA-03131 error This is caused by a uc4-value (length of OCI8-data) stored into the upper half of a sizte_t-value (length of zend_string). --- ext/oci8/oci8_statement.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index e69de4c50547..9aa81dc9f1d5 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1500,6 +1500,10 @@ sb4 php_oci_bind_out_callback( /* XXX we assume that zend-zval len has 4 bytes */ *alenpp = (ub4*) &Z_STRLEN_P(val); + if(sizeof(size_t)==2*sizeof(ub4)){ + size_t s=1; + if(*(ub4*)&s==0) ++*alenpp; + } *bufpp = Z_STRVAL_P(val); *piecep = OCI_ONE_PIECE; *rcodepp = &phpbind->retcode; From 1967c86bd09d550ccd5f174cb8de281ee06f8344 Mon Sep 17 00:00:00 2001 From: pk1234 Date: Tue, 31 Aug 2021 11:41:20 +0200 Subject: [PATCH 2/4] use WORDS_BIGENDIAN macro instead of reading first 4 bytes of (size_t)1 to detect bigendieness use WORDS_BIGENDIAN macro --- ext/oci8/oci8_statement.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 9aa81dc9f1d5..be6c056b80b8 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1500,6 +1500,11 @@ sb4 php_oci_bind_out_callback( /* XXX we assume that zend-zval len has 4 bytes */ *alenpp = (ub4*) &Z_STRLEN_P(val); +#ifdef WORDS_BIGENDIAN + // on bigendian machines ub4-length must be stored into last 4 bytes of zend_string-length + if(sizeof(zend_long)==2*sizeof(ub4)) ++*alenpp; +#endif + if(sizeof(size_t)==2*sizeof(ub4)){ size_t s=1; if(*(ub4*)&s==0) ++*alenpp; From 0d8094cab41f423cc7878ae2f7b92ada434e1300 Mon Sep 17 00:00:00 2001 From: pk1234 Date: Tue, 31 Aug 2021 11:46:18 +0200 Subject: [PATCH 3/4] delete old stuff --- ext/oci8/oci8_statement.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index be6c056b80b8..0e65649e2c32 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1504,11 +1504,6 @@ sb4 php_oci_bind_out_callback( // on bigendian machines ub4-length must be stored into last 4 bytes of zend_string-length if(sizeof(zend_long)==2*sizeof(ub4)) ++*alenpp; #endif - - if(sizeof(size_t)==2*sizeof(ub4)){ - size_t s=1; - if(*(ub4*)&s==0) ++*alenpp; - } *bufpp = Z_STRVAL_P(val); *piecep = OCI_ONE_PIECE; *rcodepp = &phpbind->retcode; From 55d044f6541db2e9eff9921795b0ac7a6921bc55 Mon Sep 17 00:00:00 2001 From: pk1234 Date: Tue, 31 Aug 2021 12:08:04 +0200 Subject: [PATCH 4/4] replace zend_long by size_t another typo - sorry for 3 commits --- ext/oci8/oci8_statement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 0e65649e2c32..0d87c77986e6 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1502,7 +1502,7 @@ sb4 php_oci_bind_out_callback( *alenpp = (ub4*) &Z_STRLEN_P(val); #ifdef WORDS_BIGENDIAN // on bigendian machines ub4-length must be stored into last 4 bytes of zend_string-length - if(sizeof(zend_long)==2*sizeof(ub4)) ++*alenpp; + if(sizeof(size_t)==2*sizeof(ub4)) ++*alenpp; #endif *bufpp = Z_STRVAL_P(val); *piecep = OCI_ONE_PIECE;