Bug #35776 driver installer (myodbc-installer.exe) fails to create a new DSN
Submitted: 2 Apr 2008 19:04 Modified: 13 May 2008 13:50
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1 OS:Windows
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: installer, MyODBC, SQLGetInstalledDriversW

[2 Apr 2008 19:04] Bogdan Degtyariov
myodbc-installer.exe (or GUI dialog) cannot create a new DSN and display the following error message:

[ERROR] SQLInstaller error 8: Cannot find driver
[ERROR] Data source entry failed, remove or try again

The error occurs only if install many other drivers in the system.
The buffer in which SQLGetInstalledDriversW() function returns the list of installed drivers is not big enough to hold all driver names and "MySQL Connector 5.1 Driver" is not stored in this buffer.

How to repeat:
Install 50 more ODBC drivers and try to add a new DSN using GUI or the command line tool.

Suggested fix:
The buffer of 65K is big enough to keep ~2000 driver records.

Index: util/installer.c
--- util/installer.c	(revision 1086)
+++ util/installer.c	(working copy)
@@ -249,16 +249,16 @@
 int driver_lookup_name(Driver *driver)
-  SQLWCHAR drivers[1024];
+  SQLWCHAR drivers[65536];
   SQLWCHAR *pdrv= drivers;
-  SQLWCHAR driverinfo[1024];
+  SQLWCHAR driverinfo[65536];
   int len;
   short slen; /* WORD needed for windows */
   /* get list of drivers */
 #ifdef _WIN32
-  if (!SQLGetInstalledDriversW(pdrv, 1023, &slen) || !(len= slen))
+  if (!SQLGetInstalledDriversW(pdrv, 65535, &slen) || !(len= slen))
   if (!(len = SQLGetPrivateProfileStringW(NULL, NULL, W_EMPTY, pdrv, 1023,
[2 Apr 2008 19:20] Bogdan Degtyariov
Buffer size is 16K (and SQLGetPrivateProfileString parameter is changed too)

Attachment: bug35776.patch (application/octet-stream, text), 812 bytes.

[3 Apr 2008 10:34] Tonci Grgin
Bug#34826 has been marked as duplicate of this report.
[4 Apr 2008 17:02] Jim Winstead
use sizeof(drivers) instead of a hard-coded length, but otherwise fine.
[4 Apr 2008 17:38] Bogdan Degtyariov
Committed into 5.1 as rev 1087, will be released in 5.1.4.
[13 May 2008 13:50] Paul DuBois
Noted in 5.1.4 changelog.

The driver installer could not create a new DSN if many other drivers
were already installed.