Skip to content

Commit 25f5a1b

Browse files
committed
Improve fix for #80783
1 parent eebcfeb commit 25f5a1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/pdo_odbc/odbc_stmt.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,13 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong
665665
256, &C->fetched_len);
666666
orig_fetched_len = C->fetched_len;
667667

668-
if (rc == SQL_SUCCESS) {
668+
if (rc == SQL_SUCCESS && C->fetched_len < 256) {
669669
/* all the data fit into our little buffer;
670670
* jump down to the generic bound data case */
671671
goto in_data;
672672
}
673673

674-
if (rc == SQL_SUCCESS_WITH_INFO) {
674+
if (rc == SQL_SUCCESS_WITH_INFO || rc == SQL_SUCCESS) {
675675
/* this is a 'long column'
676676
677677
read the column in 255 byte blocks until the end of the column is reached, reassembling those blocks
@@ -700,7 +700,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong
700700
}
701701

702702
/* resize output buffer and reassemble block */
703-
if (rc==SQL_SUCCESS_WITH_INFO) {
703+
if (rc==SQL_SUCCESS_WITH_INFO || (rc==SQL_SUCCESS && C->fetched_len > 255)) {
704704
/* point 5, in section "Retrieving Data with SQLGetData" in http://msdn.microsoft.com/en-us/library/windows/desktop/ms715441(v=vs.85).aspx
705705
states that if SQL_SUCCESS_WITH_INFO, fetched_len will be > 255 (greater than buf2's size)
706706
(if a driver fails to follow that and wrote less than 255 bytes to buf2, this will AV or read garbage into buf) */

0 commit comments

Comments
 (0)