Skip to content

Commit 9b6f83e

Browse files
authored
ext/pdo_odbc: Require non-empty string when building string buffer (#21652)
A buggy driver could do this and get PDO_ODBC stuck in this loop. Require a non-empty string, so an empty one breaks like the SQL_NO_DATA case. Fixes GH-21534
1 parent d1670fb commit 9b6f83e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/pdo_odbc/odbc_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo
710710
str = zend_string_realloc(str, used + 256, 0);
711711
memcpy(ZSTR_VAL(str) + used, buf2, 256);
712712
used = used + 255;
713-
} else if (rc==SQL_SUCCESS) {
713+
} else if (rc == SQL_SUCCESS && C->fetched_len != 0) {
714714
str = zend_string_realloc(str, used + C->fetched_len, 0);
715715
memcpy(ZSTR_VAL(str) + used, buf2, C->fetched_len);
716716
used = used + C->fetched_len;

0 commit comments

Comments
 (0)