From c18667e9f2d5140b493ed400efccae42efe9b708 Mon Sep 17 00:00:00 2001 From: whydoubt Date: Tue, 13 Apr 2004 03:17:19 +0000 Subject: [PATCH] Utilize _odbc_get_string_size() in SQLPrepare() --- ChangeLog | 1 + src/odbc/odbc.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb1ba7b..6c09d9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ Mon Apr 12 21:58:00 CDT 2004 Jeff Smith * src/odbc/connectparams.c: ODBC driver dialog enhancements * src/sql/mdbsql.c: Correct some array sizes + * src/odb/odbc.c: Utilize _odbc_get_string_size() in SQLPrepare() Mon Apr 12 09:56:23 EDT 2004 Brian Bruns * include/mdbtools: diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index fdd247e..c3b7870 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -32,7 +32,7 @@ #include "connectparams.h" -static char software_version[] = "$Id: odbc.c,v 1.16 2004/03/25 10:34:07 brianb Exp $"; +static char software_version[] = "$Id: odbc.c,v 1.17 2004/04/13 03:17:20 whydoubt Exp $"; static void *no_unused_var_warn[] = {software_version, no_unused_var_warn}; @@ -980,17 +980,15 @@ SQLRETURN SQL_API SQLPrepare( SQLCHAR FAR *szSqlStr, SQLINTEGER cbSqlStr) { -struct _hstmt *stmt=(struct _hstmt *)hstmt; + struct _hstmt *stmt=(struct _hstmt *)hstmt; + int sqllen = _odbc_get_string_size(cbSqlStr, szSqlStr); TRACE("SQLPrepare"); - if (cbSqlStr!=SQL_NTS) { - strncpy(stmt->query, szSqlStr, cbSqlStr); - stmt->query[cbSqlStr]='\0'; - } else { - strcpy(stmt->query, szSqlStr); - } - return SQL_SUCCESS; + strncpy(stmt->query, szSqlStr, sqllen); + stmt->query[sqllen]='\0'; + + return SQL_SUCCESS; } SQLRETURN SQL_API SQLRowCount(