Changeset: e7621e266962 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7621e266962
Modified Files:
        clients/ChangeLog.Aug2011
        clients/mapilib/mapi.c
Branch: Aug2011
Log Message:

Don't append partial queries inside mapi_query_part.
When using the construct
        mclient -s 'COPY INTO t FROM STDIN ...' < file.csv
mapi_query is called for the first part of the query (on the command
line) which allocates just enough space to remember that query, and
then mapi_query_part is called for each line of the input file, which
assumed the allocated space was 512 bytes, resulting in out-of-bounds
writes.


diffs (42 lines):

diff --git a/clients/ChangeLog.Aug2011 b/clients/ChangeLog.Aug2011
--- a/clients/ChangeLog.Aug2011
+++ b/clients/ChangeLog.Aug2011
@@ -1,6 +1,11 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Mon Oct 10 2011 Sjoerd Mullender <[email protected]>
+- Fixed a source of crashes in mclient when a query on the command line
+  using the -s option is combined with input on standard input (e.g. in
+  the construct mclient -s 'COPY INTO t FROM STDIN ...' < file.csv).
+
 * Fri Oct  7 2011 Sjoerd Mullender <[email protected]>
 - Fixed bug 2897 where slow (network) reads could cause blocks to not
   be fully read in one go, causing errors in the subsequent use of
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -4263,22 +4263,7 @@ mapi_query_part(MapiHdl hdl, const char 
        mid->active = hdl;
        /* remember the query just for the error messages */
        if (hdl->query == NULL) {
-               size_t sz = size;
-
-               sz = 512;
-               hdl->query = malloc(sz + 1);
-               assert(hdl->query);
-               hdl->query[0] = '\0';
-               strncpy(hdl->query, query, sz);
-               hdl->query[sz] = '\0';
-       } else {
-               size_t ln = strlen(hdl->query), sz = 512 - ln;
-               if (sz > 0) {
-                       if (size < sz)
-                               sz = size;
-                       assert(hdl->query);
-                       strncat(hdl->query, query, sz);
-               }
+               hdl->query = strdup(query);
        }
 
        if (mid->trace == MAPI_TRACE) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to