Changeset: 2a535819295e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2a535819295e
Modified Files:
        gdk/gdk_atoms.c
        gdk/gdk_heap.c
        gdk/gdk_storage.c
        gdk/gdk_utils.c
        monetdb5/mal/mal_atom.c
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/optimizer/opt_macro.c
        monetdb5/optimizer/opt_origin.c
        sql/backends/monet5/sql_scenario.c
Branch: Oct2012
Log Message:

Merge with Jul2012 branch.


diffs (169 lines):

diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -231,6 +231,7 @@ ATOMproperty(str id, str property, GDKfc
        } else if (strcmp("storage", property) == 0) {
                BATatoms[t] = BATatoms[val];    /* copy from example */
                strncpy(BATatoms[t].name, id, IDLENGTH); /* restore name */
+               BATatoms[t].name[IDLENGTH - 1] = 0;
        } else if (strcmp("fromstr", property) == 0) {
                BATatoms[t].atomFromStr = (int (*)(const char *, int *, void 
**)) arg;
        } else if (strcmp("tostr", property) == 0) {
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -308,7 +308,8 @@ HEAPalloc(Heap *h, size_t nitems, size_t
                } else {
                        char *ext;
 
-                       strcpy(nme, of);
+                       strncpy(nme, of, sizeof(nme));
+                       nme[sizeof(nme) - 1] = 0;
                        ext = decompose_filename(nme);
                        fp = GDKfilelocate(nme, "wb", ext);
                        if (fp != NULL) {
@@ -352,7 +353,8 @@ HEAPextend(Heap *h, size_t size)
        char nme[PATHLENGTH], *ext = NULL;
 
        if (h->filename) {
-               strcpy(nme, h->filename);
+               strncpy(nme, h->filename, sizeof(nme));
+               nme[sizeof(nme) - 1] = 0;
                ext = decompose_filename(nme);
        }
        if (size <= h->size)
@@ -624,7 +626,6 @@ HEAPload_intern(Heap *h, const char *nme
        int ret = 0, desc_status = 0;
        long_str srcpath, dstpath;
        struct stat st;
-       char *p;
 
        h->storage = h->newstorage;
        h->maxsize = h->size;
@@ -665,9 +666,8 @@ HEAPload_intern(Heap *h, const char *nme
         * takes precedence. */
        GDKfilepath(srcpath, BATDIR, nme, ext);
        GDKfilepath(dstpath, BATDIR, nme, ext);
-       for (p = srcpath; *p; p++)
-               ;
-       strcpy(p, suffix);
+       assert(strlen(srcpath) + strlen(suffix) < sizeof(srcpath));
+       strcat(srcpath, suffix);
        ret = stat(dstpath, &st);
        if (stat(srcpath, &st) == 0) {
                int t0;
@@ -725,8 +725,8 @@ HEAPsave_intern(Heap *h, const char *nme
        if (h->storage != STORE_MEM && store == STORE_PRIV) {
                /* anonymous or private VM is saved as if it were malloced */
                store = STORE_MEM;
-               strcpy(extension, ext);
-               strcat(extension, suffix);
+               assert(strlen(ext) + strlen(suffix) < sizeof(extension));
+               snprintf(extension, sizeof(extension), "%s%s", ext, suffix);
                ext = extension;
        } else if (store != STORE_MEM) {
                store = h->storage;
@@ -762,8 +762,8 @@ HEAPdelete(Heap *h, const char *o, const
        if (h->copied) {
                return 0;
        }
-       strcpy(ext2, ext);
-       strcat(ext2, ".new");
+       assert(strlen(ext) + strlen(".new") < sizeof(ext2));
+       snprintf(ext2, sizeof(ext2), "%s%s", ext, ".new");
        return (GDKunlink(BATDIR, o, ext) == 0) | (GDKunlink(BATDIR, o, ext2) 
== 0) ? 0 : -1;
 }
 
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -71,7 +71,9 @@ GDKcreatedir(const char *dir)
        char *r;
        int ret = FALSE;
 
-       strcpy(path, dir);
+       assert(strlen(dir) < sizeof(path));
+       strncpy(path, dir, sizeof(path)-1);
+       path[sizeof(path)-1] = 0;
        r = strrchr(path, DIR_SEP);
        IODEBUG THRprintf(GDKstdout, "#GDKcreatedir(%s)\n", path);
 
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -112,6 +112,9 @@ GDKenvironment(str dbname, str dbfarm)
        assert(strlen(dbfarm) < PATHLENGTH);
        strncpy(GDKdbnameStr, dbname, PATHLENGTH);
        strncpy(GDKdbfarmStr, dbfarm, PATHLENGTH);
+       /* make coverity happy: */
+       GDKdbnameStr[PATHLENGTH - 1] = 0;
+       GDKdbfarmStr[PATHLENGTH - 1] = 0;
        return 1;
 }
 
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -278,6 +278,7 @@ void malAtomDefinition(stream *out, str 
        if (tpe) {
                BATatoms[i] = BATatoms[tpe];
                strncpy(BATatoms[i].name, name, sizeof(BATatoms[i].name));
+               BATatoms[i].name[sizeof(BATatoms[i].name) - 1] = 0; /* make 
coverity happy */
                BATatoms[i].storage = BATatoms[tpe].storage;
        } else { /* cannot overload void atoms */
                BATatoms[i].storage = i;
@@ -299,6 +300,7 @@ int malAtomFixed(int size, int align, ch
        i = ATOMindex(name);
        BATatoms[i] = BATatoms[TYPE_bte];
        strncpy(BATatoms[i].name, name, sizeof(BATatoms[i].name));
+       BATatoms[i].name[sizeof(BATatoms[i].name) - 1] = 0;
        BATatoms[i].storage = i;
        BATatoms[i].size = size;
        assert_shift_width(ATOMelmshift(BATatoms[i].size), BATatoms[i].size);
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -486,6 +486,7 @@ SERVERlisten(int *Port, str *Usockfile, 
 
                userver.sun_family = AF_UNIX;
                strncpy(userver.sun_path, usockfile, sizeof(userver.sun_path));
+               userver.sun_path[sizeof(userver.sun_path) - 1] = 0;
 
                length = (SOCKLEN) sizeof(userver);
                unlink(usockfile);
diff --git a/monetdb5/optimizer/opt_macro.c b/monetdb5/optimizer/opt_macro.c
--- a/monetdb5/optimizer/opt_macro.c
+++ b/monetdb5/optimizer/opt_macro.c
@@ -99,7 +99,7 @@ malFcnMatch(MalBlkPtr mc, MalBlkPtr mb, 
                for (j = 0; j < p->argc; j++)
                        cvar[ctop++] = getArg(p, j);
 
-               for (j = 0; j < p->argc; j++)
+               for (j = 0; j < q->argc; j++)
                        mvar[mtop++] = getArg(q, j);
        }
        assert(mtop == ctop);   /*shouldn't happen */
diff --git a/monetdb5/optimizer/opt_origin.c b/monetdb5/optimizer/opt_origin.c
--- a/monetdb5/optimizer/opt_origin.c
+++ b/monetdb5/optimizer/opt_origin.c
@@ -83,7 +83,7 @@ OPToriginImplementation(Client cntxt, Ma
                                        varSetProp(mb, getArg(p,0), 
horiginProp, op_eq, &val);
                                }
                                if ( t ){
-                                       VALset(&val, TYPE_str, 
GDKstrdup(h->value.val.sval));
+                                       VALset(&val, TYPE_str, 
GDKstrdup(t->value.val.sval));
                                        varSetProp(mb, getArg(p,0), 
toriginProp, op_eq, &val);
                                }
                        }
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -821,7 +821,7 @@ SQLstatementIntern(Client c, str *expr, 
                        (mvc_status(m) && m->type != Q_TRANS) || !m->sym) {
                        if (!err)
                                err = mvc_status(m);
-                       if (m->errstr && *m->errstr)
+                       if (*m->errstr)
                                msg = createException(PARSE, "SQLparser", "%s", 
m->errstr);
                        *m->errstr = 0;
                        sqlcleanup(m, err);
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to