From: Nikolay Sivov nsivov@codeweavers.com
None of ODBC standard statement attributes are specified to use string values. Currently passing user pointer such as SQL_ATTR_ROW_ARRAY_SIZE could get "converted", providing driver with unrelated pointer, which is also immediately freed on return.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/odbc32/proxyodbc.c | 20 ++++++++++++++------ include/sql.h | 2 +- include/sqlext.h | 4 ++++ 3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 2b307c22793..b8967d4cd0d 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3940,14 +3940,22 @@ static SQLRETURN set_stmt_attr_win32_a( struct statement *stmt, SQLINTEGER attr,
if (stmt->hdr.win32_funcs->SQLSetStmtAttrW) { + BOOL stringvalue = !(len < SQL_LEN_BINARY_ATTR_OFFSET /* Binary buffer */ + || (len == SQL_IS_POINTER) /* Other pointer */ + || (len == SQL_IS_INTEGER || len == SQL_IS_UINTEGER)); /* Fixed-length */ WCHAR *strW;
- if (len == SQL_IS_POINTER || len < SQL_LEN_BINARY_ATTR_OFFSET) - return stmt->hdr.win32_funcs->SQLSetStmtAttrW( stmt->hdr.win32_handle, attr, value, len ); - - if (!(strW = strnAtoW( value, len ))) return SQL_ERROR; - ret = stmt->hdr.win32_funcs->SQLSetStmtAttrW( stmt->hdr.win32_handle, attr, strW, len ); - free( strW ); + /* Driver-defined attribute range */ + if (stringvalue && attr >= SQL_DRIVER_STMT_ATTR_BASE && attr <= 0x7fff) + { + if (!(strW = strnAtoW( value, len ))) return SQL_ERROR; + ret = stmt->hdr.win32_funcs->SQLSetStmtAttrW( stmt->hdr.win32_handle, attr, strW, len ); + free( strW ); + } + else + { + ret = stmt->hdr.win32_funcs->SQLSetStmtAttrW( stmt->hdr.win32_handle, attr, value, len ); + } } return ret; } diff --git a/include/sql.h b/include/sql.h index ed47380c8a3..c9a85faf9c5 100644 --- a/include/sql.h +++ b/include/sql.h @@ -22,7 +22,7 @@ #define __SQL_H
#ifndef ODBCVER -#define ODBCVER 0x0351 +#define ODBCVER 0x0380 #endif
#include <sqltypes.h> diff --git a/include/sqlext.h b/include/sqlext.h index 6a707f8e162..7f43c86da37 100644 --- a/include/sqlext.h +++ b/include/sqlext.h @@ -448,6 +448,10 @@ extern "C" { #define SQL_TYPE_MAX SQL_VARCHAR #endif
+#if (ODBCVER >= 0x0380) +#define SQL_DRIVER_STMT_ATTR_BASE 0x00004000 +#endif + #if (ODBCVER >= 0x0300) #define SQL_C_VARBOOKMARK SQL_C_BINARY #endif