php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #73002
Patch oci8_statement.patch_8_0_0 revision 2020-08-17 10:52 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_4_0boolean2 revision 2019-12-16 10:52 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_4_0boolean revision 2019-12-16 10:17 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_4_0 revision 2019-11-27 10:12 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_3_0_RC2 revision 2018-10-01 11:57 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_3_0 revision 2018-06-12 15:01 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_1_11 revision 2017-10-29 14:53 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_1_8 revision 2017-08-10 13:06 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_1_4 revision 2017-04-28 08:33 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_0_13_v2 revision 2016-11-14 19:12 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_0_13 revision 2016-11-14 12:11 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement_v2.patch_7_0_11 revision 2016-09-16 11:13 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch_7_0_11 revision 2016-09-16 10:28 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement_v2.patch revision 2016-09-08 10:22 UTC by lzsiga at freemail dot c3 dot hu
Patch oci8_statement.patch revision 2016-09-02 11:14 UTC by lzsiga at freemail dot c3 dot hu

Patch oci8_statement.patch_8_0_0 for OCI8 related Bug #73002

Patch version 2020-08-17 10:52 UTC

Return to Bug #73002 | Download this patch
Patch Revisions:

Developer: lzsiga@freemail.c3.hu

*** ext/oci8/oci8_statement.c	Tue Aug  4 19:44:52 2020
--- ../php-8.0.0beta1-patched/ext/oci8/oci8_statement.c	Fri Aug 14 10:58:49 2020
***************
*** 43,48 ****
--- 43,58 ----
  typedef ub4 oci_phpsized_int;
  #endif
  
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+   #define LongPtr2Int32Ptr(longptr) ((int32_t *)(longptr))
+   #define ZendLongPtr2Int32Ptr(zendlongptr) ((int32_t *)(zendlongptr))
+ #else
+   #define LongPtr2Int32Ptr(longptr) \
+     ((int32_t *)((char *)(longptr)+(sizeof(long)-sizeof(int32_t))))
+   #define ZendLongPtr2Int32Ptr(zendlongptr) \
+     ((int32_t *)((char *)(zendlongptr)+(sizeof(zend_long)-sizeof(int32_t))))
+ #endif
+ 
  /* {{{ php_oci_statement_create()
   Create statemend handle and allocate necessary resources */
  php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len)
***************
*** 986,1002 ****
  		}
  		zval_ptr_dtor(zv);
  		ZVAL_NULL(zv);
! 	} else if (Z_TYPE_P(zv) == IS_STRING
! 			   && Z_STRLEN_P(zv) > 0
! 			   && Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] != '\0') {
! 		/* The post- PHP 5.3 feature for "interned" strings disallows
! 		 * their reallocation but (i) any IN binds either interned or
! 		 * not should already be null terminated and (ii) for OUT
! 		 * binds, php_oci_bind_out_callback() should have allocated a
! 		 * new string that we can modify here.
! 		 */
! 		ZVAL_NEW_STR(zv, zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0));
! 		Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] = '\0';
  	} else if (Z_TYPE_P(zv) == IS_ARRAY) {
  		int i;
  		zval *entry = NULL;
--- 996,1014 ----
  		}
  		zval_ptr_dtor(zv);
  		ZVAL_NULL(zv);
! 	} else if (Z_TYPE_P(zv) == IS_STRING) {
! 		Z_STRLEN_P(zv)= bind->dummy_len;
! 		if (Z_STRLEN_P(zv) > 0 &&
! 		    Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] != '\0') {
! 			/* The post- PHP 5.3 feature for "interned" strings disallows
! 			 * their reallocation but (i) any IN binds either interned or
! 			 * not should already be null terminated and (ii) for OUT
! 			 * binds, php_oci_bind_out_callback() should have allocated a
! 			 * new string that we can modify here.
! 			 */
! 			ZVAL_NEW_STR(zv, zend_string_extend(Z_STR_P(zv), Z_STRLEN_P(zv)+1, 0));
! 			Z_STRVAL_P(zv)[ Z_STRLEN_P(zv) ] = '\0';
! 		}
  	} else if (Z_TYPE_P(zv) == IS_ARRAY) {
  		int i;
  		zval *entry = NULL;
***************
*** 1088,1094 ****
  		/* This convetrsion is done on purpose (ext/oci8 uses LVAL as a temporary value) */
  		if (Z_LVAL_P(zv) == 0)
  			ZVAL_BOOL(zv, FALSE);
! 		else if (Z_LVAL_P(zv) == 1)
  			ZVAL_BOOL(zv, TRUE);
  	}
  
--- 1100,1106 ----
  		/* This convetrsion is done on purpose (ext/oci8 uses LVAL as a temporary value) */
  		if (Z_LVAL_P(zv) == 0)
  			ZVAL_BOOL(zv, FALSE);
! 		else
  			ZVAL_BOOL(zv, TRUE);
  	}
  
***************
*** 1232,1238 ****
  				return 1;
  			}
  
! 			value_sz = sizeof(zend_long);
  
  			mode = OCI_DEFAULT;
  			break;
--- 1244,1251 ----
  				return 1;
  			}
  
! 			bind_data = ZendLongPtr2Int32Ptr (bind_data);	/* for bigendian 64-bit platform */
! 			value_sz = sizeof (int32);
  
  			mode = OCI_DEFAULT;
  			break;
***************
*** 1380,1385 ****
--- 1393,1399 ----
  		*bufpp = 0;
  		*alenp = -1;
  		*indpp = (dvoid *)&phpbind->indicator;
+ 		phpbind->dummy_len= 0;          /* so far, 'dummy_len' meant the maximum length; from now, it is the actual length */
  	} else	if ((phpbind->descriptor == 0) && (phpbind->statement == 0)) {
  		/* "normal" string bind */
  		if (!try_convert_to_string(val)) {
***************
*** 1397,1402 ****
--- 1411,1417 ----
  		if ((phpbind->dummy_len > 0) && (phpbind->dummy_len < *alenp))
  			*alenp = phpbind->dummy_len;
  		*indpp = (dvoid *)&phpbind->indicator;
+ 		phpbind->dummy_len= *alenp;	/* so far, 'dummy_len' meant the maximum length; from now, it is the actual length */
  	} else if (phpbind->statement != 0) {
  		/* RSET */
  		*bufpp = phpbind->statement;
***************
*** 1490,1497 ****
  		ZVAL_STRINGL(val, NULL, Z_STRLEN(val) + 1);
  #endif
  
! 		/* XXX we assume that zend-zval len has 4 bytes */
! 		*alenpp = (ub4*) &Z_STRLEN_P(val);
  		*bufpp = Z_STRVAL_P(val);
  		*piecep = OCI_ONE_PIECE;
  		*rcodepp = &phpbind->retcode;
--- 1505,1513 ----
  		ZVAL_STRINGL(val, NULL, Z_STRLEN(val) + 1);
  #endif
  
! 		/* XXX we assume that zend-zval len has 4 bytes -- doesn't work on big endian PowerPC-64 */
!  		phpbind->dummy_len= Z_STRLEN_P(val);
! 		*alenpp = &phpbind->dummy_len;
  		*bufpp = Z_STRVAL_P(val);
  		*piecep = OCI_ONE_PIECE;
  		*rcodepp = &phpbind->retcode;
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 27 12:01:22 2020 UTC