Skip to Content.
Sympa Menu

freetds - [freetds] [PATCH] 0.91 segfault in SQLTables

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Lionel Elie Mamane <lionel AT mamane.lu>
  • To: FreeTDS AT lists.ibiblio.org
  • Subject: [freetds] [PATCH] 0.91 segfault in SQLTables
  • Date: Thu, 2 Aug 2012 10:23:19 +0200

Hi,

Attached is the patch I apply to my local copy of FreeTDS. It solves a
segfault when connecting to MS SQL Server or Sybase SQL Anywhere from
LibreOffice, when LibreOffice calls SQLTables(). Also attached a
backtrace of the segfault.

--
Lionel
#0 0x00007fb82705365c in tds_quote (tds=0x33a3a20, buffer=0x0, quoting=93
']', id=
0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>,
len=1106707232) at query.c:2184
#1 0x00007fb82705378c in tds_quote_id (tds=0x33a3a20, buffer=0x0,
id=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>,
idlen=1106707232) at query.c:2222
#2 0x00007fb827027ff6 in odbc_stat_execute (stmt=0x34e9cc0,
begin=0x7fb8270698cf "..sp_tables", nparams=4) at odbc.c:7049
#3 0x00007fb827027492 in _SQLTables (hstmt=0x34e9cc0,
szCatalogName=0x34e5118 "APSAL", cbCatalogName=-3, szSchemaName=0x34e5138
"dbo",
cbSchemaName=-3, szTableName=0x34e4208 "ANALYTIC_VENTILATION",
cbTableName=-3, szTableType=0x34e9ee8 "VIEW,TABLE,%,", cbTableType=-3)
at odbc.c:6793
#4 0x00007fb827026d3c in SQLTables (hstmt=0x34e9cc0, szCatalogName=0x34e5118
"APSAL", cbCatalogName=-3, szSchemaName=0x34e5138 "dbo",
cbSchemaName=-3, szTableName=0x34e4208 "ANALYTIC_VENTILATION",
cbTableName=-3, szTableType=0x34e9ee8 "VIEW,TABLE,%,", cbTableType=-3)
at sqlwparams.h:113
--- freetds-0.91.orig/src/odbc/odbc.c
+++ freetds-0.91/src/odbc/odbc.c
@@ -7046,9 +7046,9 @@
 			len += strlen(params[i].name) + odbc_quote_metadata(stmt->dbc, params[i].type, NULL, 
 									    &params[i].value) + 3;
 			if (begin[0] == '.' && strstr(params[i].name, "qualifier")) {
+				param_qualifier = i;
 				len += tds_quote_id(stmt->dbc->tds_socket, NULL,
 						    tds_dstr_cstr(&params[param_qualifier].value), tds_dstr_len(&params[param_qualifier].value));
-				param_qualifier = i;
 			}
 		}
 



Archive powered by MHonArc 2.6.24.

Top of Page