Skip to content

Commit b5b964b

Browse files
committed
clobber wrappers for strval, strlen, dtor
1 parent 042897f commit b5b964b

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

ibm_db2.c

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
ZEND_DECLARE_MODULE_GLOBALS(ibm_db2)
3939

40-
#define ZEND_Z_STRVAL_PP(data) Z_STRVAL_P(*data)
41-
4240
#define ZEND_FETCH_RESOURCE_NEW(res, stmt_type, stmt, stmt_id, resource_type_name, le_stmt)\
4341
res = (stmt_type) zend_fetch_resource(Z_RES_P(*stmt),resource_type_name,le_stmt);\
4442
if(res == NULL)\
@@ -57,17 +55,13 @@ RETVAL_STRING(str); \
5755
efree(str);\
5856
return
5957

60-
#define ZEND_ZVAL_PTR_DTOR(data) zval_ptr_dtor(data)
61-
6258
#define IBM_DB2_ZEND_GET_TYPE(data) (data)->u1.v.type
6359
#define RES_GET_TYPE(zval) (zval)->type
6460

6561
#define ZEND_Z_TYPE_RESOURCE(newEntry) RES_GET_TYPE(&newEntry)
6662

6763
#define ZEND_Z_TYPE(entry) IBM_DB2_ZEND_GET_TYPE(&entry)
6864

69-
#define ZEND_Z_STRLEN_PP(value) Z_STRLEN_P(*value)
70-
7165
#define ZEND_Z_TYPE_P(entry) IBM_DB2_ZEND_GET_TYPE(entry)
7266

7367
#define ZEND_Z_TYPE_PP(entry) ZEND_Z_TYPE_P(*entry)
@@ -990,7 +984,7 @@ static void _php_db2_free_result_struct(stmt_handle* handle)
990984

991985
if( prev_ptr->param_type != DB2_PARAM_OUT && prev_ptr->param_type != DB2_PARAM_INOUT ) {
992986
if (prev_ptr->value) {
993-
ZEND_ZVAL_PTR_DTOR(prev_ptr->value);
987+
zval_ptr_dtor(prev_ptr->value);
994988
}
995989
}
996990
efree(prev_ptr);
@@ -1580,7 +1574,7 @@ static void _php_db2_assign_options( void *handle, int type, char *opt_key, zval
15801574
char *option_str = NULL;
15811575

15821576
if (ZEND_Z_TYPE_PP(data) == IS_STRING) {
1583-
option_str = ZEND_Z_STRVAL_PP(data);
1577+
option_str = Z_STRVAL_P(*data);
15841578
} else {
15851579
option_num = Z_LVAL_P(*data);
15861580
}
@@ -4637,7 +4631,7 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
46374631
platform_pad = 0x20;
46384632
}
46394633
/* IBM i has no CHAR0 type (zero length null term string) */
4640-
if (ZEND_Z_STRLEN_PP(data) == 0 || ZEND_Z_STRVAL_PP(data)[0] == '\0') {
4634+
if (Z_STRLEN_P(*data) == 0 || Z_STRVAL_P(*data)[0] == '\0') {
46414635
switch (isvarying) {
46424636
case 0: /* need full *BLANKS */
46434637
platform_need_full_pad = 1;
@@ -4670,7 +4664,7 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
46704664
}
46714665

46724666
/* current length */
4673-
*poriglen = ZEND_Z_STRLEN_PP(data);
4667+
*poriglen = Z_STRLEN_P(*data);
46744668

46754669
/*
46764670
* IS_INTERNED() macro to check if a given char* is interned or regular string
@@ -4679,9 +4673,9 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
46794673
*/
46804674
if (IS_INTERNED(Z_STR_P(*data))) {
46814675
/* Need use macro assignment to avoid leak in php 7. (Thanks Dimitry)
4682-
* Z_STR_P(*data) = zend_string_init(ZEND_Z_STRVAL_PP(data), ZEND_Z_STRLEN_PP(data), 0);
4676+
* Z_STR_P(*data) = zend_string_init(Z_STRVAL_P(*data), Z_STRLEN_P(*data), 0);
46834677
*/
4684-
ZVAL_STR(*data, zend_string_init(ZEND_Z_STRVAL_PP(data), ZEND_Z_STRLEN_PP(data), 0));
4678+
ZVAL_STR(*data, zend_string_init(Z_STRVAL_P(*data), Z_STRLEN_P(*data), 0));
46854679
}
46864680

46874681
/* make enough space for full write */
@@ -4691,27 +4685,27 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
46914685
*/
46924686
ZVAL_STR(*data, zend_string_extend(Z_STR_P(*data), curr->param_size + nullterm, 0));
46934687
if (platform_need_full_pad) {
4694-
memset(ZEND_Z_STRVAL_PP(data), platform_pad, curr->param_size + nullterm);
4688+
memset(Z_STRVAL_P(*data), platform_pad, curr->param_size + nullterm);
46954689
} else {
4696-
memset(ZEND_Z_STRVAL_PP(data) + *poriglen, platform_pad, curr->param_size - *poriglen);
4690+
memset(Z_STRVAL_P(*data) + *poriglen, platform_pad, curr->param_size - *poriglen);
46974691
}
46984692
#ifdef PASE /* i5/OS -- do not remove length-1, breaks IBM i. Also null orig len breaks IBM i. */
46994693
if (nullterm) {
4700-
ZEND_Z_STRVAL_PP(data)[curr->param_size] = '\0';
4694+
Z_STRVAL_P(*data)[curr->param_size] = '\0';
47014695
}
4702-
ZEND_Z_STRLEN_PP(data) = curr->param_size; /* yes, length-1 for bind parm max */
4696+
Z_STRLEN_P(*data) = curr->param_size; /* yes, length-1 for bind parm max */
47034697
*poriglen = curr->param_size;
47044698
#else
47054699
if (nullterm) {
4706-
ZEND_Z_STRVAL_PP(data)[*poriglen] = '\0';
4700+
Z_STRVAL_P(*data)[*poriglen] = '\0';
47074701
}
4708-
ZEND_Z_STRLEN_PP(data) = curr->param_size; /* yes, length-1 for bind parm max */
4702+
Z_STRLEN_P(*data) = curr->param_size; /* yes, length-1 for bind parm max */
47094703
#endif /* PASE */
47104704
}
47114705

47124706
/* IBM i has no CHAR0 type (return to normal) */
47134707
if (dreadPirateCHAR0 == 1) {
4714-
ZEND_Z_STRVAL_PP(data)[0] = platform_pad;
4708+
Z_STRVAL_P(*data)[0] = platform_pad;
47154709
dreadPirateCHAR0 = 0;
47164710
curr->param_type = save_param_type;
47174711
switch(platform_need_full_pad) {
@@ -4725,7 +4719,7 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
47254719
}
47264720

47274721
/* something went very wrong with heap */
4728-
if (ZEND_Z_STRVAL_PP(data) == NULL ) {
4722+
if (Z_STRVAL_P(*data) == NULL ) {
47294723
return SQL_ERROR;
47304724
}
47314725

@@ -4746,8 +4740,8 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
47464740
* '2' becomes '000000000000000000002'
47474741
*/
47484742
case SQL_BIGINT:
4749-
front=ZEND_Z_STRVAL_PP(data);
4750-
here=back=ZEND_Z_STRVAL_PP(data) + ZEND_Z_STRLEN_PP(data) - nullterm;
4743+
front=Z_STRVAL_P(*data);
4744+
here=back=Z_STRVAL_P(*data) + Z_STRLEN_P(*data) - nullterm;
47514745
for (;here>=front;here--) {
47524746
if (*here == '-') {
47534747
isNeg = 1;
@@ -4803,7 +4797,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
48034797

48044798
/* Clean old zval value and create a new one */
48054799
if( curr->value != 0 && curr->param_type != DB2_PARAM_OUT && curr->param_type != DB2_PARAM_INOUT )
4806-
ZEND_ZVAL_PTR_DTOR(curr->value);
4800+
zval_ptr_dtor(curr->value);
48074801
if (!curr->value) {
48084802
curr->value = (zval *)emalloc(sizeof(zval));
48094803
}
@@ -4879,7 +4873,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
48794873
if (ZEND_Z_TYPE_PP(bind_data) == IS_NULL){
48804874
break;
48814875
}
4882-
/* make sure copy in is a string (ZEND_Z_STRVAL_PP(bind_data) && ) */
4876+
/* make sure copy in is a string (Z_STRVAL_P(*bind_data) && ) */
48834877
if (*bind_data && ZEND_Z_TYPE_PP(bind_data) != IS_STRING) {
48844878
convert_to_string(*bind_data);
48854879
}
@@ -7088,7 +7082,7 @@ PHP_FUNCTION(db2_server_info)
70887082

70897083
add_property_zval(return_value, "KEYWORDS", karray);
70907084

7091-
ZEND_ZVAL_PTR_DTOR(karray);
7085+
zval_ptr_dtor(karray);
70927086
}
70937087

70947088
/* DFT_ISOLATION */
@@ -7159,7 +7153,7 @@ PHP_FUNCTION(db2_server_info)
71597153

71607154
add_property_zval(return_value, "ISOLATION_OPTION", array);
71617155

7162-
ZEND_ZVAL_PTR_DTOR(array);
7156+
zval_ptr_dtor(array);
71637157
}
71647158

71657159
/* SQL_CONFORMANCE */

0 commit comments

Comments
 (0)