Changeset: 59034d699c54 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/59034d699c54
Modified Files:
        clients/odbc/driver/ODBCUtil.c
        common/options/monet_options.c
        common/stream/url_stream.c
        common/utils/mutils.c
        common/utils/muuid.c
        gdk/gdk_bat.c
Branch: Sep2022
Log Message:

A couple of fixes.


diffs (141 lines):

diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -1214,6 +1214,8 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
                                                                                
        }
                                                                                
}
                                                                        }
+                                                                       if 
(repl == NULL)
+                                                                               
break;
                                                                }
                                                                size_t l = i + 
strlen(repl) + 2 + arglen + strlen(rest) - j + 1 + strlen(repl2) + repl3len;
                                                                nquery = 
malloc(l);
diff --git a/common/options/monet_options.c b/common/options/monet_options.c
--- a/common/options/monet_options.c
+++ b/common/options/monet_options.c
@@ -139,8 +139,7 @@ mo_config_file(opt **Set, int setlen, ch
                val = strchr(s, '=');
                if (val == NULL) {
                        fprintf(stderr, "mo_config_file: syntax error in %s at 
%s\n", file, s);
-                       fclose(fd);
-                       exit(1);
+                       break;
                }
                *val = 0;
 
@@ -162,8 +161,7 @@ mo_config_file(opt **Set, int setlen, ch
                }
                if (quote) {
                        fprintf(stderr, "mo_config_file: wrong number of quotes 
in %s at %s\n", file, val);
-                       fclose(fd);
-                       exit(1);
+                       break;
                }
                /* remove trailing white space */
                while (isspace((unsigned char) t[-1]))
@@ -176,7 +174,7 @@ mo_config_file(opt **Set, int setlen, ch
 
                opt *tmp = realloc(set, (setlen + 1) * sizeof(opt));
                if (tmp == NULL)
-                       return setlen;
+                       break;
                *Set = set = tmp;
                set[setlen].kind = opt_config;
                set[setlen].name = strdup(s);
@@ -184,7 +182,7 @@ mo_config_file(opt **Set, int setlen, ch
                if (set[setlen].name == NULL || set[setlen].value == NULL) {
                        free(set[setlen].name);
                        free(set[setlen].value);
-                       return setlen;
+                       break;
                }
                for (t = val, s = set[setlen].value; *t; t++)
                        if (*t != '"')
diff --git a/common/stream/url_stream.c b/common/stream/url_stream.c
--- a/common/stream/url_stream.c
+++ b/common/stream/url_stream.c
@@ -171,16 +171,16 @@ open_urlstream(const char *url)
                return NULL;
        }
        s->stream_data.p = (void *) c;
-       curl_easy_setopt(c->handle, CURLOPT_URL, s->name);
-       curl_easy_setopt(c->handle, CURLOPT_WRITEDATA, s);
-       curl_easy_setopt(c->handle, CURLOPT_VERBOSE, 0);
-       curl_easy_setopt(c->handle, CURLOPT_NOSIGNAL, 1);
-       curl_easy_setopt(c->handle, CURLOPT_FAILONERROR, 1);
-       curl_easy_setopt(c->handle, CURLOPT_ERRORBUFFER, c->errbuf);
-       curl_easy_setopt(c->handle, CURLOPT_WRITEFUNCTION, write_callback);
-       CURLcode ret = curl_easy_perform(c->handle);
-       if (ret != CURLE_OK) {
-               if (strlen(c->errbuf) > 0)
+       CURLcode ret;
+       if ((ret = curl_easy_setopt(c->handle, CURLOPT_ERRORBUFFER, c->errbuf)) 
!= CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_URL, s->name)) != 
CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_WRITEDATA, s)) != 
CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_VERBOSE, 0)) != 
CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_NOSIGNAL, 1)) != 
CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_FAILONERROR, 1)) != 
CURLE_OK ||
+               (ret = curl_easy_setopt(c->handle, CURLOPT_WRITEFUNCTION, 
write_callback)) != CURLE_OK ||
+               (ret = curl_easy_perform(c->handle)) != CURLE_OK) {
+               if (c->errbuf[0] != 0)
                        mnstr_set_open_error(url, 0, "%s", c->errbuf);
                else
                        mnstr_set_open_error(url, 0, "curl_easy_perform: %s", 
curl_easy_strerror(ret));
diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -797,12 +797,15 @@ MT_lockf(const char *filename, int mode)
                                fd = fp->fd;
                                free(fp);
                                seek = lseek(fd, 4, SEEK_SET);
+                               if (seek < 0)
+                                       seek = 0;       /* should never happen, 
just for coverity */
                                int ret = lockf(fd, mode, 1);
                                (void) lseek(fd, seek, SEEK_SET); /* move seek 
pointer back */
                                /* do not close fd, it is closed by caller */
                                return ret;             /* 0 if unlock 
successful, -1 if not */
                        }
                }
+               pthread_mutex_unlock(&cs);
        }
        fd = open(filename, O_CREAT | O_RDWR | O_TEXT | O_CLOEXEC, 
MONETDB_MODE);
 
diff --git a/common/utils/muuid.c b/common/utils/muuid.c
--- a/common/utils/muuid.c
+++ b/common/utils/muuid.c
@@ -71,12 +71,18 @@ generateUUID(void)
                /* generate something like this:
                 * cefa7a9c-1dd2-41b2-8350-880020adbeef
                 * ("%08x-%04x-%04x-%04x-%012x") */
+#ifdef __COVERITY__
+               /* avoid rand() when checking with coverity */
+               snprintf(out, sizeof(out),
+                                "00000000-0000-0000-0000-000000000000");
+#else
                snprintf(out, sizeof(out),
                         "%04x%04x-%04x-4%03x-8%03x-%04x%04x%04x",
                         (unsigned) rand() & 0xFFFF, (unsigned) rand() & 0xFFFF,
                         (unsigned) rand() & 0xFFFF, (unsigned) rand() & 0x0FFF,
                         (unsigned) rand() & 0x0FFF, (unsigned) rand() & 0xFFFF,
                         (unsigned) rand() & 0xFFFF, (unsigned) rand() & 
0xFFFF);
+#endif
        }
        return strdup(out);
 }
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1027,7 +1027,12 @@ BUNappendmulti(BAT *b, const void *value
        }
 
        MT_lock_set(&b->theaplock);
-       ALIGNapp(b, force, GDK_FAIL);
+       if (!force && (b->batRestricted == BAT_READ ||
+                      b->batSharecnt > 0)) {
+               MT_lock_unset(&b->theaplock);
+               GDKerror("access denied to %s, aborting.\n", BATgetId(b));
+               return GDK_FAIL;
+       }
        MT_lock_unset(&b->theaplock);
        /* load hash so that we can maintain it */
        (void) BATcheckhash(b);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to