From 5888c4a52ca636f629dbf11969c13c3373a10242 Mon Sep 17 00:00:00 2001 From: William Rogers Date: Fri, 22 May 2015 20:10:10 -0500 Subject: [PATCH] Correction to SQLGetData string length handling According to http://download.oracle.com/otn_hosted_doc/timesten/703/TimesTen-Documentation/ms.odbc.pdf and https://msdn.microsoft.com/en-us/library/ms710980(v=vs.85).aspx, the string length should not include the NULL character at the end. Previous behavior would likely work without problems for any language that uses C-style null terminated strings, but adds a null character in the string when using the driver with a language that does not use C-style strings. --- src/odbc/odbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index 86f8bd0..faf1974 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -1797,7 +1797,7 @@ static SQLRETURN SQL_API _SQLGetData( { char *str = mdb_col_to_string(mdb, mdb->pg_buf, col->cur_value_start, col->col_type, col->cur_value_len); - int len = strlen(str) + 1; // including \0 + int len = strlen(str); if (stmt->pos >= len) { free(str); return SQL_NO_DATA;