Update of /cvsroot/monetdb/clients/src/mapilib
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25928
Modified Files:
Tag: Clients_1-20
Mapi.mx
Log Message:
make sure we 1) do not leak hostname and database names
2) do use parts of the challence string as the
hostname and database name (ie do strdup)
This should fix the crash on gentoo.
Index: Mapi.mx
===================================================================
RCS file: /cvsroot/monetdb/clients/src/mapilib/Mapi.mx,v
retrieving revision 1.24.2.1
retrieving revision 1.24.2.2
diff -u -d -r1.24.2.1 -r1.24.2.2
--- Mapi.mx 2 Oct 2007 11:49:21 -0000 1.24.2.1
+++ Mapi.mx 16 Nov 2007 12:33:36 -0000 1.24.2.2
@@ -2382,7 +2382,7 @@
case '^':{
/* FIXME: there may be multiple
redirects */
char *tmp = result->cache.line[i].rows;
- char *tmp2 = "";
+ char *tmp2 = "", *p = NULL, *db = NULL;
/* redirect, looks like:
*
^mapi:monetdb://localhost:50001/test?lang=sql&user=monetdb */
@@ -2400,23 +2400,26 @@
/* parse components (we store the args
* immediately in the mid... ok, that's
dirty */
tmp += strlen("mapi:monetdb://");
- mid->hostname = tmp;
+ p = tmp;
if ((tmp = strchr(tmp, ':')) != NULL) {
*tmp++ = '\0';
tmp2 = tmp;
} else {
- tmp = mid->hostname;
+ tmp = p;
}
if ((tmp = strchr(tmp, '/')) != NULL) {
*tmp++ = '\0';
mid->port = atoi(tmp2);
if (mid->port == 0)
goto err;
- mid->database = tmp;
+ db = tmp;
} else {
- tmp = mid->hostname;
+ tmp = p;
goto err;
}
+ if (mid->hostname)
+ free(mid->hostname);
+ mid->hostname = strdup(p);
if ((tmp = strchr(tmp, '?')) != NULL) {
char *tmp3;
@@ -2454,6 +2457,10 @@
} else
goto err;
} /* no optional arguments
(weird) */
+ if (mid->database)
+ free(mid->database);
+ mid->database = (db)?strdup(db):NULL;
+
mid->redircnt++;
mapi_close_handle(hdl);
/* reconnect using the new values */
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins