MonetDB: Jun2023 - We need to escape the underscore.

2023-11-14 Thread Sjoerd Mullender via checkin-list
Changeset: 0f0dec27b78c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0f0dec27b78c
Modified Files:
documentation/source/manual_pages/monetdb.rst
Branch: Jun2023
Log Message:

We need to escape the underscore.
Else we get the error `(ERROR/3) Unknown target name: "a-za-z0-9".'


diffs (12 lines):

diff --git a/documentation/source/manual_pages/monetdb.rst 
b/documentation/source/manual_pages/monetdb.rst
--- a/documentation/source/manual_pages/monetdb.rst
+++ b/documentation/source/manual_pages/monetdb.rst
@@ -71,7 +71,7 @@ allows to do wildcard matches. For detai
maintenance mode. This allows the database administrator to perform
initialization steps before releasing it to users, unless the **-p**
argument is supplied. See also **monetdb lock**. The name of the
-   database must match the expression [A-Za-z0-9_-]+.
+   database must match the expression [A-Za-z0-9\_-]+.
 
**-m**\ *pattern*
   With the **-m** flag, instead of creating a database, a
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Coverity found some issues...

2023-11-14 Thread Sjoerd Mullender via checkin-list
Changeset: 90393719b085 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/90393719b085
Modified Files:
clients/mapilib/connect.c
clients/mapilib/connect_openssl.c
clients/mapilib/connect_unix.c
clients/mapilib/mapi.c
clients/mapilib/msettings.c
Branch: Dec2023
Log Message:

Coverity found some issues...


diffs (109 lines):

diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -111,7 +111,9 @@ scan_sockets(Mapi mid)
errmsg = allocated_errmsg;
}
if (errmsg) {
-   return mapi_setError(mid, errmsg, __func__, MERROR);
+   MapiMsg err = mapi_setError(mid, errmsg, __func__, MERROR);
+   free(allocated_errmsg);
+   return err;
}
return establish_connection(mid);
 }
@@ -697,11 +699,13 @@ mapi_handshake(Mapi mid)
) {
mapi_close_handle(hdl);
close_connection(mid);
-   return mapi_printError(
+   MapiMsg err = mapi_printError(
mid, __func__, MERROR,
"%s: %s",
error_message ? error_message : 
"invalid redirect",
red);
+   free(error_message);
+   return err;
}
 
if (strncmp("mapi:merovingian", red, 16) == 0) {
diff --git a/clients/mapilib/connect_openssl.c 
b/clients/mapilib/connect_openssl.c
--- a/clients/mapilib/connect_openssl.c
+++ b/clients/mapilib/connect_openssl.c
@@ -342,21 +342,25 @@ wrap_tls(Mapi mid, SOCKET sock)
BIO_free_all(bio); // drops first ref
BIO_free_all(bio); // drops second ref
free(hostcolonport);
-   return croak_openssl(mid, __func__, "openssl_rstream: %s", 
mnstr_peek_error(rstream));
+   msg = croak_openssl(mid, __func__, "openssl_rstream: %s", 
mnstr_peek_error(rstream));
+   close_stream(rstream);
+   return msg;
}
// On error: free 'bio' and close 'rstream'.
stream *wstream = openssl_wstream(hostcolonport ? hostcolonport : "ssl 
wstream", bio);
free(hostcolonport);
if (wstream == NULL || mnstr_errnr(wstream) != MNSTR_NO__ERROR) {
BIO_free_all(bio);
-   mnstr_close(rstream);
-   return croak_openssl(mid, __func__, "openssl_wstream: %s", 
mnstr_peek_error(wstream));
+   close_stream(rstream);
+   msg = croak_openssl(mid, __func__, "openssl_wstream: %s", 
mnstr_peek_error(wstream));
+   close_stream(wstream);
+   return msg;
}
// On error: free 'rstream' and 'wstream'.
msg = mapi_wrap_streams(mid, rstream, wstream);
if (msg != MOK) {
-   mnstr_close(rstream);
-   mnstr_close(wstream);
+   close_stream(rstream);
+   close_stream(wstream);
return msg;
}
// 'rstream' and 'wstream' are part of 'mid' now.
diff --git a/clients/mapilib/connect_unix.c b/clients/mapilib/connect_unix.c
--- a/clients/mapilib/connect_unix.c
+++ b/clients/mapilib/connect_unix.c
@@ -70,6 +70,7 @@ scan_unix_sockets(Mapi mid)
candidates[ncandidates].port = port;
candidates[ncandidates++].priority = st.st_uid == me ? 
0 : 1;
}
+   closedir(dir);
}
 
mapi_log_record(mid, "CONN", "Found %d Unix domain sockets", 
ncandidates);
@@ -180,5 +181,3 @@ connect_socket_unix(Mapi mid)
 
return wrap_socket(mid, s);
 }
-
-
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1847,7 +1847,7 @@ set_uri(Mapi mid)
const char *host = msetting_string(mid->settings, MP_HOST);
const char *database = msetting_string(mid->settings, MP_DATABASE);
int port = msetting_long(mid->settings, MP_PORT);
-   size_t urilen = strlen(host) + strlen(database) + 32;
+   size_t urilen = strlen(host) + (database ? strlen(database) : 0) + 32;
char *uri = malloc(urilen);
 
/* uri looks as follows:
diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c
--- a/clients/mapilib/msettings.c
+++ b/clients/mapilib/msettings.c
@@ -572,7 +572,7 @@ validate_certhash(msettings *mp)
if (i < sizeof(mp->certhash_digits_buffer) - 1)
mp->certhash_digits_buffer[i++] = tolower(*r);
}
-   mp->certhash_digits_buffer[i++] = '\0';
+   mp->certhash_digits_buffer[i] = '\0';
if (i == 0)
return "certhash: need at least one digit";
 
@@ -

MonetDB: Dec2023 - Dead code; possible NULL dereference; possibl...

2023-11-14 Thread Sjoerd Mullender via checkin-list
Changeset: 9c4769a6042f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c4769a6042f
Modified Files:
geom/monetdb5/geod.c
geom/monetdb5/geom.c
geom/monetdb5/geomBulk.c
Branch: Dec2023
Log Message:

Dead code; possible NULL dereference; possible memory leak.


diffs (109 lines):

diff --git a/geom/monetdb5/geod.c b/geom/monetdb5/geod.c
--- a/geom/monetdb5/geod.c
+++ b/geom/monetdb5/geod.c
@@ -1027,7 +1027,9 @@ filterJoinGeomGeomDoubleToBit(bat *lres_
BUN est;
 
//get the input BATs
-   if ((l = BATdescriptor(*l_id)) == NULL || (r = BATdescriptor(*r_id)) == 
NULL) {
+   l = BATdescriptor(*l_id);
+   r = BATdescriptor(*r_id);
+   if (l == NULL || r == NULL) {
if (l)
BBPunfix(l->batCacheid);
if (r)
@@ -1170,8 +1172,6 @@ wkbDWithinGeographicJoin(bat *lres_id, b
BAT *d = NULL;
//Get the distance BAT and get the double value
if ((d = BATdescriptor(*d_id)) == NULL) {
-   if (d)
-   BBPunfix(d->batCacheid);
throw(MAL, "geom.wkbDWithinGeographicJoin", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
}
if (BATcount(d) == 1) {
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -163,12 +163,6 @@ wkbCollectAggrSubGroupedCand(bat *outid,

GDKfree(unions[i]);
GDKfree(unions);
}
-   if (unionGroup) {
-   for (BUN i = 0; i < 
geomCount; i++)
-   if 
(unionGroup[i])
-   
GEOSGeom_destroy(unionGroup[i]);
-   GDKfree(unionGroup);
-   }
goto free;
}
}
@@ -241,8 +235,6 @@ wkbCollectAggr (wkb **out, const bat *bi
 
if ((b = BATdescriptor(*bid)) == NULL) {
msg = createException(MAL, "geom.Collect", 
RUNTIME_OBJECT_MISSING);
-   if (b)
-   BBPunfix(b->batCacheid);
return msg;
}
 
@@ -3572,6 +3564,10 @@ wkbMakeLineAggrSubGroupedCand(bat *outid
if (lastGrp != (oid)-1) {
msg = wkbMakeLineAggrArray(&lines[lastGrp], 
lineGroup, position);
position = 0;
+   if (msg != MAL_SUCCEED) {
+   GDKfree(lineGroup);
+   goto free;
+   }
}
lastGrp = grp;
}
@@ -3579,6 +3575,8 @@ wkbMakeLineAggrSubGroupedCand(bat *outid
}
msg = wkbMakeLineAggrArray(&lines[lastGrp], lineGroup, position);
GDKfree(lineGroup);
+   if (msg != MAL_SUCCEED)
+   goto free;
 
if (BUNappendmulti(out, lines, ngrp, false) != GDK_SUCCEED) {
msg = createException(MAL, "geom.Union", SQLSTATE(38000) 
"BUNappend operation failed");
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -787,15 +787,6 @@ wkbTransform_bat_cand(bat *outBAT_id, ba
oid p = (canditer_next(&ci) - inBAT->hseqbase);
geomWKB = (wkb *) BUNtvar(inBAT_iter, p);
 
-   if (geomWKB == NULL) {
-   bat_iterator_end(&inBAT_iter);
-   BBPunfix(inBAT->batCacheid);
-   BBPunfix(outBAT->batCacheid);
-   if (s)
-   BBPunfix(s->batCacheid);
-   throw(MAL, "batgeom.Transform", SQLSTATE(38000) "One of 
the wkb geometries is null");
-   }
-
/* get the geosGeometry from the wkb */
geosGeometry = wkb2geos(geomWKB);
/* get the type of the geometry */
@@ -930,16 +921,12 @@ wkbDistanceGeographic_bat_cand(bat *out_
 bailout:
bat_iterator_end(&a_iter);
bat_iterator_end(&b_iter);
-   if (s1)
-   BBPunfix(s1->batCacheid);
-   if (s2)
-   BBPunfix(s2->batCacheid);
+   BBPreclaim(s1);
+   BBPreclaim(s2);
 clean:
-   if (a)
-   BBPunfix(a->batCacheid);
-   if (b)
-   BBPunfix(b->batCacheid);
-   BBPunfix(out->batCacheid);
+   BBPreclaim(a);
+   BBPreclaim(b);
+   BBPreclaim(out);
return msg;
 }
 
___
checkin-list m

MonetDB: Dec2023 - Minor fixes to make coverity happier.

2023-11-14 Thread Sjoerd Mullender via checkin-list
Changeset: d662aa1707fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d662aa1707fe
Modified Files:
monetdb5/mal/mal_listing.c
monetdb5/modules/kernel/algebra.c
monetdb5/modules/mal/mal_mapi.c
Branch: Dec2023
Log Message:

Minor fixes to make coverity happier.


diffs (92 lines):

diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c
--- a/monetdb5/mal/mal_listing.c
+++ b/monetdb5/mal/mal_listing.c
@@ -301,7 +301,7 @@ fmtRemark(MalBlkPtr mb, MalStkPtr stk, I
if (!copystring(&t, "# ", &len))
return base;
 
-   if (pci && pci->argc == 3) {
+   if (pci->argc == 3) {
if (getFunctionId(pci)) {
char *arg1 = renderTerm(mb, stk, pci, 1, flg);
char *arg2 = renderTerm(mb, stk, pci, 2, flg);
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -413,12 +413,11 @@ ALGmarkselect(bat *r1, bat *r2, const ba
assert(g->tsorted);
oid *ri1 = Tloc(res1, 0);
bit *ri2 = Tloc(res2, 0);
-   oid *gi = Tloc(g, 0);
bit *mi = Tloc(m, 0);
bit *pi = Tloc(p, 0);
oid cur = oid_nil;
 
-   if (!gi) { /* void case ? */
+   if (g->ttype == TYPE_void) { /* void case ? */
oid c = g->hseqbase;
for (BUN n = 0; n < nr; n++, c++) {
ri1[q] = c;
@@ -430,6 +429,7 @@ ALGmarkselect(bat *r1, bat *r2, const ba
q++;
}
} else {
+   oid *gi = Tloc(g, 0);
oid c = g->hseqbase;
if (nr)
cur = gi[0];
@@ -507,12 +507,11 @@ ALGouterselect(bat *r1, bat *r2, const b
assert(g->tsorted);
oid *ri1 = Tloc(res1, 0);
bit *ri2 = Tloc(res2, 0);
-   oid *gi = Tloc(g, 0);
bit *mi = Tloc(m, 0);
bit *pi = Tloc(p, 0);
oid cur = oid_nil;
 
-   if (!gi) { /* void case ? */
+   if (g->ttype == TYPE_void) { /* void case ? */
oid c = g->hseqbase;
for (BUN n = 0; n < nr; n++, c++) {
ri1[q] = c;
@@ -520,6 +519,7 @@ ALGouterselect(bat *r1, bat *r2, const b
q++;
}
} else {
+   oid *gi = Tloc(g, 0);
oid c = g->hseqbase;
if (nr)
cur = gi[0];
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
@@ -704,7 +704,13 @@ SERVERlisten(int port, const char *usock
}
char sport[10];
snprintf(sport, sizeof(sport), "%d", port);
-   GDKsetenv("mapi_port", sport);
+   if (GDKsetenv("mapi_port", sport) != GDK_SUCCEED) {
+   for (int i = 0; i < 3; i++) {
+   if (socks[i] != INVALID_SOCKET)
+   closesocket(socks[i]);
+   }
+   throw(MAL, "mal_mapi.listen", GDK_EXCEPTION);
+   }
}
 
 #ifdef HAVE_SYS_UN_H
@@ -814,7 +820,13 @@ SERVERlisten(int port, const char *usock
GDKfree(usockfilenew);
return buf;
}
-   GDKsetenv("mapi_usock", usockfile);
+   if (GDKsetenv("mapi_usock", usockfile) != GDK_SUCCEED) {
+   for (int i = 0; i < 3; i++) {
+   if (socks[i] != INVALID_SOCKET)
+   closesocket(socks[i]);
+   }
+   throw(MAL, "mal_mapi.listen", GDK_EXCEPTION);
+   }
}
 #endif
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Merge with Jun2023 branch.

2023-11-14 Thread Sjoerd Mullender via checkin-list
Changeset: 754d484ed114 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/754d484ed114
Branch: Dec2023
Log Message:

Merge with Jun2023 branch.


diffs (12 lines):

diff --git a/documentation/source/manual_pages/monetdb.rst 
b/documentation/source/manual_pages/monetdb.rst
--- a/documentation/source/manual_pages/monetdb.rst
+++ b/documentation/source/manual_pages/monetdb.rst
@@ -71,7 +71,7 @@ allows to do wildcard matches. For detai
maintenance mode. This allows the database administrator to perform
initialization steps before releasing it to users, unless the **-p**
argument is supplied. See also **monetdb lock**. The name of the
-   database must match the expression [A-Za-z0-9_-]+.
+   database must match the expression [A-Za-z0-9\_-]+.
 
**-m**\ *pattern*
   With the **-m** flag, instead of creating a database, a
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org