Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix #80460: ODBC doesn't account for SQL_NO_TOTAL indicator
This commit is contained in:
Christoph M. Becker 2021-04-27 17:11:17 +02:00
commit 4c80e439a8
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
2 changed files with 39 additions and 1 deletions

3
NEWS
View File

@ -12,6 +12,9 @@ PHP NEWS
- FTP:
. Fixed bug #80901 (Info leak in ftp extension). (cmb)
- ODBC:
. Fixed bug #80460 (ODBC doesn't account for SQL_NO_TOTAL indicator). (cmb)
- pgsql:
. Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb)

View File

@ -1447,6 +1447,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
} else if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1, rc);
ZVAL_FALSE(&tmp);
} else {
ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
}
@ -1456,6 +1459,10 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1, rc);
ZVAL_FALSE(&tmp);
break;
}
ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
break;
@ -1600,6 +1607,9 @@ PHP_FUNCTION(odbc_fetch_into)
} else if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1, rc);
ZVAL_FALSE(&tmp);
} else {
ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
}
@ -1609,6 +1619,10 @@ PHP_FUNCTION(odbc_fetch_into)
if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1, rc);
ZVAL_FALSE(&tmp);
break;
}
ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
break;
@ -1836,6 +1850,10 @@ PHP_FUNCTION(odbc_result)
} else if (result->values[field_ind].vallen == SQL_NULL_DATA) {
zend_string_efree(field_str);
RETURN_NULL();
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
zend_string_efree(field_str);
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1, rc);
RETURN_FALSE;
}
/* Reduce fieldlen by 1 if we have char data. One day we might
have binary strings... */
@ -1859,6 +1877,9 @@ PHP_FUNCTION(odbc_result)
default:
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
RETURN_NULL();
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1, rc);
RETURN_FALSE;
} else {
RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen);
}
@ -1890,6 +1911,10 @@ PHP_FUNCTION(odbc_result)
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
efree(field);
RETURN_NULL();
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1, rc);
efree(field);
RETURN_FALSE;
}
/* chop the trailing \0 by outputting only 4095 bytes */
PHPWRITE(field,(rc == SQL_SUCCESS_WITH_INFO) ? 4095 : result->values[field_ind].vallen);
@ -1994,7 +2019,14 @@ PHP_FUNCTION(odbc_result_all)
RETURN_FALSE;
}
if (rc == SQL_SUCCESS_WITH_INFO) {
PHPWRITE(buf, result->longreadlen);
if (result->values[i].vallen == SQL_NO_TOTAL) {
php_printf("</td></tr></table>");
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (driver cannot determine length)", i + 1, rc);
efree(buf);
RETURN_FALSE;
} else {
PHPWRITE(buf, result->longreadlen);
}
} else if (rc != SQL_SUCCESS) {
php_printf("</td></tr></table>");
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (retcode %u)", i + 1, rc);
@ -2011,6 +2043,9 @@ PHP_FUNCTION(odbc_result_all)
default:
if (result->values[i].vallen == SQL_NULL_DATA) {
php_printf("<td>NULL</td>");
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (driver cannot determine length)", i + 1, rc);
php_printf("<td>FALSE</td>");
} else {
php_printf("<td>%s</td>", result->values[i].value);
}