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";
@@ -844,4 +844,3 @@ msettings_lang_is_sql(const msettings *m
{
return mp->lang_is_sql;
}
-
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]