diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-16 10:53:48 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-16 10:53:48 +0100 |
commit | 1a66d64717d08e9b7f7c9328be673018cfe28c11 (patch) | |
tree | 40d39efd70079182d66ea2db6aafeb481dc12e84 /ext/mysqlnd | |
parent | f6bd3dfdbcc0d8f4f7733560034e735865083c1a (diff) | |
parent | 315f3f8dc9b3ba3639c9284301933286fc99a825 (diff) | |
download | php-git-1a66d64717d08e9b7f7c9328be673018cfe28c11.tar.gz |
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
Fixed bug #67983
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 33a000d9a6..1fc2941e66 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -1604,8 +1604,28 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval * } MYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1, STAT_BYTES_RECEIVED_PURE_DATA_TEXT, len); } + if (fields_metadata[i].type == MYSQL_TYPE_BIT) { + /* + BIT fields are specially handled. As they come as bit mask, they have + to be converted to human-readable representation. + */ + ps_fetch_from_1_to_8_bytes(current_field, &(fields_metadata[i]), 0, (const zend_uchar **) &p, len); + /* + We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because + later in this function there will be an advancement. + */ + p -= len; + if (Z_TYPE_P(current_field) == IS_LONG && !as_int_or_float) { + /* we are using the text protocol, so convert to string */ + char tmp[22]; + const size_t tmp_len = sprintf((char *)&tmp, ZEND_ULONG_FMT, Z_LVAL_P(current_field)); + ZVAL_STRINGL(current_field, tmp, tmp_len); + } else if (Z_TYPE_P(current_field) == IS_STRING) { + /* nothing to do here, as we want a string and ps_fetch_from_1_to_8_bytes() has given us one */ + } + } #ifdef MYSQLND_STRING_TO_INT_CONVERSION - if (as_int_or_float && perm_bind.php_type == IS_LONG) { + else if (as_int_or_float && perm_bind.php_type == IS_LONG) { zend_uchar save = *(p + len); /* We have to make it ASCIIZ temporarily */ *(p + len) = '\0'; @@ -1649,28 +1669,9 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval * *(p + len) = '\0'; ZVAL_DOUBLE(current_field, atof((char *) p)); *(p + len) = save; - } else + } #endif /* MYSQLND_STRING_TO_INT_CONVERSION */ - if (fields_metadata[i].type == MYSQL_TYPE_BIT) { - /* - BIT fields are specially handled. As they come as bit mask, they have - to be converted to human-readable representation. - */ - ps_fetch_from_1_to_8_bytes(current_field, &(fields_metadata[i]), 0, (const zend_uchar **) &p, len); - /* - We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because - later in this function there will be an advancement. - */ - p -= len; - if (Z_TYPE_P(current_field) == IS_LONG && !as_int_or_float) { - /* we are using the text protocol, so convert to string */ - char tmp[22]; - const size_t tmp_len = sprintf((char *)&tmp, ZEND_ULONG_FMT, Z_LVAL_P(current_field)); - ZVAL_STRINGL(current_field, tmp, tmp_len); - } else if (Z_TYPE_P(current_field) == IS_STRING) { - /* nothing to do here, as we want a string and ps_fetch_from_1_to_8_bytes() has given us one */ - } - } else { + else { ZVAL_STRINGL_FAST(current_field, (char *)p, len); } p += len; |