Skip to content

Commit

Permalink
Improve fix for #80783
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Apr 8, 2021
1 parent eebcfeb commit 25f5a1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/pdo_odbc/odbc_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,13 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong
256, &C->fetched_len);
orig_fetched_len = C->fetched_len;

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

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

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

0 comments on commit 25f5a1b

Please sign in to comment.