commit 384e037: [Minor] Fix some more issues

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Sep 21 11:28:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-21 12:27:10 +0100
URL: https://github.com/rspamd/rspamd/commit/384e037f52b933fdd3cb84966208f8e658212ffe (HEAD -> master)

[Minor] Fix some more issues
Found by: coverity scan

---
 src/libserver/http/http_router.c |  1 +
 src/libserver/logger/logger.c    | 23 ++++++++++++++---------
 src/libserver/milter.c           |  8 ++++----
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/libserver/http/http_router.c b/src/libserver/http/http_router.c
index 960df0ce3..9ff1195ad 100644
--- a/src/libserver/http/http_router.c
+++ b/src/libserver/http/http_router.c
@@ -199,6 +199,7 @@ rspamd_http_router_try_file (struct rspamd_http_connection_entry *entry,
 	rspamd_http_router_insert_headers (entry->rt, reply_msg);
 
 	if (!rspamd_http_message_set_body_from_fd (reply_msg, fd)) {
+		rspamd_http_message_free (reply_msg);
 		close (fd);
 		return FALSE;
 	}
diff --git a/src/libserver/logger/logger.c b/src/libserver/logger/logger.c
index f65d0fb2e..07625bb91 100644
--- a/src/libserver/logger/logger.c
+++ b/src/libserver/logger/logger.c
@@ -227,16 +227,21 @@ rspamd_log_open_specific (rspamd_mempool_t *pool,
 
 	const struct rspamd_logger_funcs *funcs = NULL;
 
-	switch (cfg->log_type) {
-	case RSPAMD_LOG_CONSOLE:
+	if (cfg) {
+		switch (cfg->log_type) {
+		case RSPAMD_LOG_CONSOLE:
+			funcs = &console_log_funcs;
+			break;
+		case RSPAMD_LOG_SYSLOG:
+			funcs = &syslog_log_funcs;
+			break;
+		case RSPAMD_LOG_FILE:
+			funcs = &file_log_funcs;
+			break;
+		}
+	}
+	else {
 		funcs = &console_log_funcs;
-		break;
-	case RSPAMD_LOG_SYSLOG:
-		funcs = &syslog_log_funcs;
-		break;
-	case RSPAMD_LOG_FILE:
-		funcs = &file_log_funcs;
-		break;
 	}
 
 	g_assert (funcs != NULL);
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 301c26a1f..142f50c92 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -846,25 +846,25 @@ rspamd_milter_consume_input (struct rspamd_milter_session *session,
 		case st_len_1:
 			/* The first length byte in big endian order */
 			priv->parser.datalen = 0;
-			priv->parser.datalen |= *p << 24;
+			priv->parser.datalen |= ((gsize)*p) << 24;
 			priv->parser.state = st_len_2;
 			p++;
 			break;
 		case st_len_2:
 			/* The second length byte in big endian order */
-			priv->parser.datalen |= *p << 16;
+			priv->parser.datalen |= ((gsize)*p) << 16;
 			priv->parser.state = st_len_3;
 			p++;
 			break;
 		case st_len_3:
 			/* The third length byte in big endian order */
-			priv->parser.datalen |= *p << 8;
+			priv->parser.datalen |= ((gsize)*p) << 8;
 			priv->parser.state = st_len_4;
 			p++;
 			break;
 		case st_len_4:
 			/* The fourth length byte in big endian order */
-			priv->parser.datalen |= *p;
+			priv->parser.datalen |= ((gsize)*p);
 			priv->parser.state = st_read_cmd;
 			p++;
 			break;


More information about the Commits mailing list