Subject: | Username and password are not added to the dsn string |
Reproducing the error:
DBI->connect("dbi:ODBC:DSN=myserver", "username", "password");
DBD-ODBC is expected to add the "username" and "password" strings to the
DSN specified (resulting "DSN=myserver;UID=username;PWD=password"), but
it's not adding them in the releases 1.37 and above (there might be
other versions affected).
The problem is in the dsnHasDriverOrDSN function in the dbdimp.c file as
it returns false even if the dsn string starts with "DSN=".
dbdimp.c:533:
*cp++ = toupper(*cp);
This increments the cp pointer first, then converts it to uppercase.
This omits the first letter from the result string so the comparison to
"DSN=" will be incorrect.
I've attached my patch (against 1.39) to the issue which fixed the
problem for me.
Subject: | dbdimp.c.diff |
--- DBD-ODBC-1.39/dbdimp.c 2012-07-07 08:14:24.000000000 -0400
+++ DBD-ODBC-1.39.patched/dbdimp.c 2012-08-24 10:09:37.000000000 -0400
@@ -530,7 +530,8 @@
strncpy(upper_dsn, dsn, sizeof(upper_dsn)-1);
upper_dsn[sizeof(upper_dsn)-1] = '\0';
while (*cp != '\0') {
- *cp++ = toupper(*cp);
+ *cp = toupper(*cp);
+ cp++;
}
return (strncmp(upper_dsn, "DSN=", 4) == 0 ||
strncmp(upper_dsn, "DRIVER=", 7) == 0);