Skip to content

Commit 22ebfb7

Browse files
committed
Try to use out_length for bound fetched values
I have no idea why it's using strlen in the first place, but if SQL/CLI returns junk in the buffer, then the length might be correct. This matches what we did with column names on IBM i. The SQL_BINARY case is more puzzling, but we can take a look at it later if this works for strings. Why is it ifdef'd to use strlen/out_length depending on platform?
1 parent eccd5a9 commit 22ebfb7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ibm_db2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6289,7 +6289,7 @@ static void _php_db2_bind_fetch_helper(INTERNAL_FUNCTION_PARAMETERS, int op)
62896289
case SQL_DECFLOAT:
62906290
#ifdef PASE /* i5/OS trim spaces */
62916291
if (stmt_res->s_i5_conn_parent->c_i5_char_trim > 0) {
6292-
i5trim = strlen((char *)row_data->str_val);
6292+
i5trim = out_length;
62936293
for(; i5trim >= 0; i5trim--) {
62946294
i5char = (char)(((char *)row_data->str_val)[i5trim]);
62956295
if (i5char == 0x00 || i5char == 0x20) {
@@ -6316,11 +6316,11 @@ static void _php_db2_bind_fetch_helper(INTERNAL_FUNCTION_PARAMETERS, int op)
63166316
#endif /* PASE */
63176317
if ( op & DB2_FETCH_ASSOC ) {
63186318
add_assoc_stringl(return_value, (char *)stmt_res->column_info[i].name,
6319-
(char *)row_data->str_val, strlen((char *)row_data->str_val));
6319+
(char *)row_data->str_val, out_length);
63206320
}
63216321
if ( op & DB2_FETCH_INDEX ) {
63226322
add_index_stringl(return_value, i, (char *)row_data->str_val,
6323-
strlen((char *)row_data->str_val));
6323+
out_length);
63246324
}
63256325
break;
63266326
case SQL_BOOLEAN:

0 commit comments

Comments
 (0)