Bug #39085 MyODBC 5.1 fails to connect if connection string parameters have preceding space

Submitted: 28 Aug 2008 8:55 Modified: 26 Nov 2008 11:28
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.5 OS:Any
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: connection string, SQLConnect

[28 Aug 2008 8:55] Bogdan Degtyariov
Description:
MyODBC Driver 5.1.5 (unlikely to 3.51) is not able to connect if connection string parameters contain spaces or tab symbols. For instance if specify the SERVER parameter as "SERVER= localhost" instead of "SERVER=localhost" the following error message will be displayed:

[MySQL][ODBC 5.1 Driver] Unknown MySQL server host ' localhost' (11001).

How to repeat:
Use the following connection string to connect to MySQL server:

"DRIVER={MySQL ODBC 5.1 Driver};SERVER= localhost;USER=dbuser;PASSWORD=******;DATABASE=mydatabase;"

Suggested fix:
=== modified file 'util/stringutil.c'
--- util/stringutil.c	2008-04-15 08:03:35 +0000
+++ util/stringutil.c	2008-08-28 08:40:28 +0000
@@ -526,7 +526,12 @@
 {
   while (*wstr != wchr && *wstr++);
   if (*wstr == wchr)
+  {
+    while(((*(wstr + 1) == (SQLWCHAR)' ') ||
+           (*(wstr + 1) == (SQLWCHAR)'\t')) &&
+          *wstr++);
     return wstr;
+  }
   else
     return NULL;
 }

(the full bzr diff with the test case is coming soon)
[28 Aug 2008 12:37] Bogdan Degtyariov
Bug fix

Attachment: patch39085.diff (application/octet-stream, text), 1.89 KiB.

[28 Aug 2008 23:43] Jim Winstead
I don't think that adding this to sqlwcharchr() is correct. Calls to sqlwcharignorespaces() could (should?) be added in spots like ds_from_kvpair().
[29 Aug 2008 11:28] Bogdan Degtyariov
patch v2 and test case

Attachment: patch39085v2.diff (application/octet-stream, text), 2.10 KiB.

[29 Aug 2008 11:29] Bogdan Degtyariov
Jim,

thanks for your comment. Please take a look at the 2nd version of the patch
[29 Aug 2008 21:56] Jim Winstead
except for the incorrect tab usage, it looks fine. please double-check your commits for whitespace issues (tabs, \r, etc, not the whitespace the issue is about).
[2 Sep 2008 22:18] Jess Balint
Should this also handle spaces after the value, before the ';' or end? eg, "user=  jess  ;pwd=123"
[16 Sep 2008 4:39] Bogdan Degtyariov
New patch that cuts spaces before and after the connection string option

Attachment: patch39085v4.diff (application/octet-stream, text), 2.23 KiB.

[26 Nov 2008 11:28] Tony Bedford
An entry was added to the 5.1.6 changelog:

MyODBC Driver 5.1.5 was not able to connect if the connection string parameters contained spaces or tab symbols. For example, if the SERVER parameter was specified as “SERVER= localhost” instead of “SERVER=localhost” the following error message will be displayed:

[MySQL][ODBC 5.1 Driver] Unknown MySQL server host ' localhost' (11001).

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.