[Commits] [SCM] claws branch, master, updated. 3.10.0-59-ga053d99

Colin colin at claws-mail.org
Thu Jun 5 17:58:50 CEST 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  a053d99543384865be56583236ef0c0def17a25e (commit)
      from  81dbf3df2f3b5e3bd761c020694115a5f71c46d8 (commit)


- Log -----------------------------------------------------------------
commit a053d99543384865be56583236ef0c0def17a25e
Author: Colin Leroy <colin at colino.net>
Date:   Thu Jun 5 17:58:08 2014 +0200

    Fix Coverity issues in common

diff --git a/src/common/smtp.c b/src/common/smtp.c
index e540d1f..888b0b2 100644
--- a/src/common/smtp.c
+++ b/src/common/smtp.c
@@ -586,7 +586,6 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
 	case SMTP_READY:
 		if (strstr(msg, "ESMTP"))
 			smtp_session->is_esmtp = TRUE;
-	case SMTP_CONNECTED:
 #ifdef USE_GNUTLS
 		if (smtp_session->user || session->ssl_type != SSL_NONE ||
 		    smtp_session->is_esmtp)
diff --git a/src/common/smtp.h b/src/common/smtp.h
index 2e78b1f..706a097 100644
--- a/src/common/smtp.h
+++ b/src/common/smtp.h
@@ -61,7 +61,6 @@ typedef enum
 typedef enum
 {
 	SMTP_READY,
-	SMTP_CONNECTED,
 	SMTP_HELO,
 	SMTP_EHLO,
 	SMTP_STARTTLS,
diff --git a/src/common/socket.c b/src/common/socket.c
index 1fe2714..946293a 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -238,7 +238,7 @@ void refresh_resolvers(void)
 #ifdef G_OS_WIN32
 #define SOCKET_IS_VALID(s)      ((s) != INVALID_SOCKET)
 #else
-#define SOCKET_IS_VALID(s) 	TRUE
+#define SOCKET_IS_VALID(s) 	(s != -1)
 #endif
 
 /* Due to the fact that socket under Windows are not represented by
diff --git a/src/common/ssl.c b/src/common/ssl.c
index 1c7c335..c56a948 100644
--- a/src/common/ssl.c
+++ b/src/common/ssl.c
@@ -275,6 +275,9 @@ gnutls_x509_crt_t *ssl_get_certificate_chain(gnutls_session_t session, gint *lis
 	if (raw_cert_list && gnutls_certificate_type_get(session) == GNUTLS_CRT_X509) {
 		int i = 0;
 
+		if (*list_len > 128)
+			*list_len = 128;
+
 		certs = g_malloc(sizeof(gnutls_x509_crt_t) * (*list_len));
 
 		for(i = 0 ; i < (*list_len) ; i++) {
diff --git a/src/common/ssl_certificate.c b/src/common/ssl_certificate.c
index 7fbfe5d..0a8b828 100644
--- a/src/common/ssl_certificate.c
+++ b/src/common/ssl_certificate.c
@@ -553,6 +553,11 @@ static guint check_cert(SSLCertificate *cert)
 		char *fingerprint;
 
 		fp = g_fopen(chain_file, "r");
+		if (fp == NULL) {
+			debug_print("fopen %s failed: %s\n", chain_file, strerror(errno));
+			g_free(chain_file);
+			return (guint)-1;
+		}
 		if ((r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &chain, &max_certs)) < 0) {
 			debug_print("chain import failed: %s\n", gnutls_strerror(r));
 			fclose(fp);
@@ -1067,7 +1072,7 @@ gchar *ssl_certificate_get_subject_cn(SSLCertificate *cert)
 
 	if(gnutls_x509_crt_get_dn_by_oid(cert->x509_cert, 
 		GNUTLS_OID_X520_COMMON_NAME, 0, 0, subject_cn, &n))
-		strncpy(subject_cn, _("<not in certificate>"), BUFFSIZE);
+		return g_strdup(_("<not in certificate>"));
 
 	return g_strdup(subject_cn);
 }
diff --git a/src/common/template.c b/src/common/template.c
index 3fcbda2..b49b7d9 100644
--- a/src/common/template.c
+++ b/src/common/template.c
@@ -280,8 +280,9 @@ static void template_write_config(GSList *tmpl_list)
 		TRY_NO_CLOSE(fclose(fp) != EOF);
 
 		if (new) {
-			claws_unlink(filename);
-			rename_force(new, filename);
+			if (rename_force(new, filename) < 0) {
+				FILE_OP_ERROR(new, "rename");
+			}
 		}
 		g_free(new);
 		g_free(filename);
diff --git a/src/common/utils.c b/src/common/utils.c
index a592ce9..cca8c18 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -3102,6 +3102,8 @@ FILE *get_tmpfile_in_dir(const gchar *dir, gchar **filename)
 #else
 	*filename = g_strdup_printf("%s%cclaws.XXXXXX", dir, G_DIR_SEPARATOR);
 	fd = mkstemp(*filename);
+	if (fd < 0)
+		return NULL;
 #endif
 	return fdopen(fd, "w+");
 }
@@ -4777,10 +4779,17 @@ void mailcap_update_default(const gchar *type, const gchar *command)
 	path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap", NULL);
 	outpath = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap.new", NULL);
 	FILE *fp = g_fopen(path, "rb");
-	FILE *outfp = g_fopen(outpath, "wb");
+	FILE *outfp = NULL;
 	gchar buf[BUFFSIZE];
 	gboolean err = FALSE;
 
+	if (!fp) {
+		g_free(path);
+		g_free(outpath);
+		return;
+	}
+
+	outfp = g_fopen(outpath, "wb");
 	if (!outfp) {
 		g_free(path);
 		g_free(outpath);
@@ -5262,8 +5271,7 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt
 				format++;
 				break;
 			default:
-				if (format && *format)
-					g_warning("format error (%c)", *format);
+				g_warning("format error (%c)", *format);
 				*curpos = '\0';
 				return total_done;
 			}
diff --git a/src/common/xmlprops.c b/src/common/xmlprops.c
index 0e0d3b8..dea67f4 100644
--- a/src/common/xmlprops.c
+++ b/src/common/xmlprops.c
@@ -264,12 +264,12 @@ static void xmlprops_save_property(
 static void xmlprops_read_props( XmlProperty *props, XMLFile *file ) {
 	GList *attr;
 	gchar *name, *value;
-	gchar pName[ ATTR_BUFSIZE ];
-	gchar pValue[ ATTR_BUFSIZE ];
+	gchar *pName;
+	gchar *pValue;
 
 	while( TRUE ) {
-		*pName = '\0';
-		*pValue = '\0';
+		pName = g_strdup("");
+		pValue = g_strdup("");
 		if (! file->level ) break;
 		xml_parse_next_tag( file );
 		xml_get_current_tag( file );
@@ -279,15 +279,19 @@ static void xmlprops_read_props( XmlProperty *props, XMLFile *file ) {
 				name = ( ( XMLAttr * ) attr->data )->name;
 				value = ( ( XMLAttr * ) attr->data )->value;
 				if( strcmp( name, XMLS_ATTAG_NAME ) == 0 ) {
-					strcpy( pName, value );
+					g_free(pName);
+					pName = g_strdup( value );
 				}
 				else if( strcmp( name, XMLS_ATTAG_VALUE ) == 0 ) {
-					strcpy( pValue, value );
+					g_free(pValue);
+					pValue = g_strdup( value );
 				}
 				attr = g_list_next( attr );
 			}
 			xmlprops_save_property( props, pName, pValue );
 		}
+		g_free(pName);
+		g_free(pValue);
 	}
 }
 
diff --git a/src/send_message.c b/src/send_message.c
index 80c0fb7..d048630 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -475,7 +475,6 @@ static gint send_recv_message(Session *session, const gchar *msg, gpointer data)
 
 	switch (smtp_session->state) {
 	case SMTP_READY:
-	case SMTP_CONNECTED:
 		return 0;
 	case SMTP_HELO:
 		g_snprintf(buf, sizeof(buf), _("Sending HELO..."));

-----------------------------------------------------------------------

Summary of changes:
 src/common/smtp.c            |    1 -
 src/common/smtp.h            |    1 -
 src/common/socket.c          |    2 +-
 src/common/ssl.c             |    3 +++
 src/common/ssl_certificate.c |    7 ++++++-
 src/common/template.c        |    5 +++--
 src/common/utils.c           |   14 +++++++++++---
 src/common/xmlprops.c        |   16 ++++++++++------
 src/send_message.c           |    1 -
 9 files changed, 34 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list