Changeset: c266f0b3a02e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c266f0b3a02e
Modified Files:
        clients/mapiclient/mclient.c
Branch: comment-on
Log Message:

Remove potential buffer overrun in mclient


diffs (29 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2504,10 +2504,15 @@ doFile(Mapi mid, stream *fp, int useinse
 #endif
                                        } else {
                                                /* get all object names in 
current schema */
-                                               char query[4096], *q = query, 
*endq = query + sizeof(query);
+                                               size_t len = 500 + strlen(line);
+                                               char *query = malloc(len);
+                                               char *q = query, *endq = query 
+ len;
                                                char *name_column = hasSchema ? 
"fullname" : "name";
 
-                                               /*
+                                               if (!query)
+                                                       return 1;
+
+                                                       /*
                                                 * | LINE            | SCHEMA 
FILTER | NAME FILTER                   |
                                                 * 
|-----------------+---------------+-------------------------------|
                                                 * | ""              | yes      
     | -                             |
@@ -2531,6 +2536,7 @@ doFile(Mapi mid, stream *fp, int useinse
                                                q += snprintf(q, endq - q, 
";\n");
 
                                                hdl = mapi_query(mid, query);
+                                               free(query);
                                                CHECK_RESULT(mid, hdl, 
continue, buf, fp);
                                                while (fetch_row(hdl) == 3) {
                                                        char *type = 
mapi_fetch_field(hdl, 0);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to