List:Commits« Previous MessageNext Message »
From:jwinstead Date:May 31 2007 11:19pm
Subject:Connector/ODBC 3.51 commit: r460 - in trunk: . driver test
View as plain text  
Modified:
   trunk/ChangeLog
   trunk/driver/execute.c
   trunk/test/my_basics.c
Log:
Calls to SQLNativeSql could cause stack corruption due to an incorrect
pointer cast. (Bug #28758)


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-31 17:01:30 UTC (rev 459)
+++ trunk/ChangeLog	2007-05-31 21:19:38 UTC (rev 460)
@@ -5,6 +5,8 @@
     but must be enabled through configuration files or the DSN. (Bug #12918)
 
   Bugs fixed:
+  * Calls to SQLNativeSql could cause stack corruption due to an incorrect
+    pointer cast. (Bug #28758)
   * SQLSetPos could update or delete the wrong rows when the original result
     set did not contain all columns of a multi-part primary key. (Bug #28255)
   * SQLTables() did not distinguish tables from views. (Bug #23031)

Modified: trunk/driver/execute.c
===================================================================
--- trunk/driver/execute.c	2007-05-31 17:01:30 UTC (rev 459)
+++ trunk/driver/execute.c	2007-05-31 21:19:38 UTC (rev 460)
@@ -737,15 +737,19 @@
                                SQLINTEGER cbSqlStrMax,
                                SQLINTEGER *pcbSqlStr)
 {
-    ulong offset= 0;
+  SQLRETURN rc;
+  SQLLEN    len= (pcbSqlStr ? *pcbSqlStr : 0);
+  ulong     offset= 0;
 
-    MYODBCDbgEnter;
+  MYODBCDbgEnter;
 
-    MYODBCDbgReturnReturn( copy_lresult(SQL_HANDLE_DBC, hdbc,
-                                 szSqlStr,cbSqlStrMax,
-                                 (SQLLEN *)pcbSqlStr,
-                                 (char*) szSqlStrIn, cbSqlStrIn,0L,0L,
-                                 &offset,0));
+  rc= copy_lresult(SQL_HANDLE_DBC, hdbc, szSqlStr, cbSqlStrMax, &len,
+                   (char *)szSqlStrIn, cbSqlStrIn, 0L, 0L, &offset, 0);
+
+  if (pcbSqlStr)
+    *pcbSqlStr= (SQLINTEGER)len;
+
+  MYODBCDbgReturnReturn(rc);
 }
 
 

Modified: trunk/test/my_basics.c
===================================================================
--- trunk/test/my_basics.c	2007-05-31 17:01:30 UTC (rev 459)
+++ trunk/test/my_basics.c	2007-05-31 21:19:38 UTC (rev 460)
@@ -177,6 +177,14 @@
   ok_con(hdbc, SQLNativeSql(hdbc, in, SQL_NTS, out, sizeof(out), &len));
   is_num(len, (SQLINTEGER) sizeof(in) - 1);
 
+  /*
+   The second call is to make sure the first didn't screw up the stack.
+   (Bug #28758)
+  */
+
+  ok_con(hdbc, SQLNativeSql(hdbc, in, SQL_NTS, out, sizeof(out), &len));
+  is_num(len, (SQLINTEGER) sizeof(in) - 1);
+
   return OK;
 }
 

Thread
Connector/ODBC 3.51 commit: r460 - in trunk: . driver testjwinstead31 May