[Commits] [SCM] claws branch, master, updated. 3.11.1-220-g99738a9

charles at claws-mail.org charles at claws-mail.org
Fri Jul 17 04:36:32 CEST 2015


The branch, master has been updated
       via  99738a91f6c2ca14fb8feeef9be42904556cf97f (commit)
       via  cf75891c808c2c9052a05776917eae0ef429ce8b (commit)
      from  8e72324cbcafe6bdbe04edd83dacc4f99636d3e1 (commit)

Summary of changes:
 src/plugins/managesieve/managesieve.c   |   41 ++++++++++++++++++-------------
 src/plugins/managesieve/managesieve.h   |    1 +
 src/plugins/managesieve/sieve_manager.c |   34 ++++++++++++++-----------
 3 files changed, 44 insertions(+), 32 deletions(-)


- Log -----------------------------------------------------------------
commit 99738a91f6c2ca14fb8feeef9be42904556cf97f
Author: Charles Lehner <cel at celehner.com>
Date:   Thu Jul 16 18:55:12 2015 -0400

    managesieve: Fix string memory leaks

diff --git a/src/plugins/managesieve/sieve_manager.c b/src/plugins/managesieve/sieve_manager.c
index 199dbba..9e89bad 100644
--- a/src/plugins/managesieve/sieve_manager.c
+++ b/src/plugins/managesieve/sieve_manager.c
@@ -171,6 +171,7 @@ static void filter_got_data(SieveSession *session, gchar *contents,
 	SieveEditorPage *editor;
 
 	if (!contents) {
+		g_free(cmd_data->filter_name);
 		g_free(cmd_data);
 		return;
 	} else if (contents == (void *)-1) {
@@ -222,12 +223,14 @@ static void filter_renamed(SieveSession *session, gboolean success,
 
 	if (!success) {
 		got_session_error(session, "Unable to rename script", page);
-		return;
-	}
-
-	manager_sessions_foreach(cur, session, page) {
-		filters_list_rename_filter(page, data->name_old, data->name_new);
+	} else {
+		manager_sessions_foreach(cur, session, page) {
+			filters_list_rename_filter(page, data->name_old,
+					data->name_new);
+		}
 	}
+	g_free(data->name_old);
+	g_free(data->name_new);
 	g_free(data);
 }
 
@@ -266,12 +269,12 @@ static void filter_activated(SieveSession *session, gboolean success,
 
 	if (!success) {
 		got_session_error(session, "Unable to set active script", page);
-		return;
-	}
-
-	manager_sessions_foreach(cur, session, page) {
-		filter_set_active(page, cmd_data->filter_name);
+	} else {
+		manager_sessions_foreach(cur, session, page) {
+			filter_set_active(page, cmd_data->filter_name);
+		}
 	}
+	g_free(cmd_data->filter_name);
 	g_free(cmd_data);
 }
 
@@ -297,12 +300,13 @@ static void filter_deleted(SieveSession *session, const gchar *err_msg,
 
 	if (err_msg) {
 		got_session_error(session, err_msg, page);
-		return;
-	}
-
-	manager_sessions_foreach(cur, session, page) {
-		filters_list_delete_filter(page, cmd_data->filter_name);
+	} else {
+		manager_sessions_foreach(cur, session, page) {
+			filters_list_delete_filter(page,
+					cmd_data->filter_name);
+		}
 	}
+	g_free(cmd_data->filter_name);
 	g_free(cmd_data);
 }
 

commit cf75891c808c2c9052a05776917eae0ef429ce8b
Author: Charles Lehner <cel at celehner.com>
Date:   Thu Jul 16 17:58:47 2015 -0400

    managesieve: handle lines starting with "OK"
    
    Count octets instead of waiting for OK

diff --git a/src/plugins/managesieve/managesieve.c b/src/plugins/managesieve/managesieve.c
index 4c67904..a6d7bbb 100644
--- a/src/plugins/managesieve/managesieve.c
+++ b/src/plugins/managesieve/managesieve.c
@@ -20,6 +20,7 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
+#include <ctype.h>
 
 #include "claws.h"
 #include "account.h"
@@ -439,22 +440,22 @@ static void unquote_inplace(gchar *str)
 
 static void parse_response(gchar *msg, SieveResult *result)
 {
+	gchar *end;
+
 	/* response status */
-	gchar *end = strchr(msg, ' ');
-	if (end)
-		*end++ = '\0';
-	result->success = strcmp(msg, "OK") == 0;
-	result->has_status = TRUE;
-	if (!end) {
-		result->code = SIEVE_CODE_NONE;
-		result->description = NULL;
-		result->has_octets = FALSE;
-		result->octets = 0;
-		return;
+	if (isalpha(msg[0])) {
+		end = strchr(msg, ' ');
+		if (end) {
+			*end++ = '\0';
+			while (*end == ' ')
+				end++;
+		}
+		result->success = strcmp(msg, "OK") == 0;
+		result->has_status = TRUE;
+		msg = end;
+	} else {
+		result->has_status = FALSE;
 	}
-	while (*end == ' ')
-		end++;
-	msg = end;
 
 	/* response code */
 	if (msg[0] == '(' && (end = strchr(msg, ')'))) {
@@ -673,17 +674,23 @@ static gint sieve_session_recv_msg(Session *session, const gchar *msg)
 		} else {
 			parse_response((gchar *)msg, &result);
 			sieve_session->state = SIEVE_GETSCRIPT_DATA;
+			/* account for newline */
+			sieve_session->octets_remaining = result.octets + 1;
 		}
 		ret = SE_OK;
 		break;
 	case SIEVE_GETSCRIPT_DATA:
-		if (response_is_ok(msg)) {
+		if (sieve_session->octets_remaining > 0) {
+			sieve_session->current_cmd->cb(sieve_session,
+					(gchar *)msg,
+					sieve_session->current_cmd->data);
+			sieve_session->octets_remaining -= strlen(msg) + 1;
+		} else if (response_is_ok(msg)) {
 			sieve_session->state = SIEVE_READY;
 			sieve_session->current_cmd->cb(sieve_session, NULL,
 					sieve_session->current_cmd->data);
 		} else {
-			sieve_session->current_cmd->cb(sieve_session, (gchar *)msg,
-					sieve_session->current_cmd->data);
+			log_warning(LOG_PROTOCOL, _("error occurred on SIEVE session\n"));
 		}
 		ret = SE_OK;
 		break;
diff --git a/src/plugins/managesieve/managesieve.h b/src/plugins/managesieve/managesieve.h
index b775f90..c150d4a 100644
--- a/src/plugins/managesieve/managesieve.h
+++ b/src/plugins/managesieve/managesieve.h
@@ -114,6 +114,7 @@ struct SieveSession
 	GSList *send_queue;
 	SieveErrorValue error;
 	SieveCommand *current_cmd;
+	guint octets_remaining;
 
 	gboolean use_auth;
 	SieveAuthType avail_auth_type;

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list