[Commits] [SCM] claws branch, master, updated. 3.11.1-185-ge184b18

ticho at claws-mail.org ticho at claws-mail.org
Wed Jul 1 18:48:07 CEST 2015


The branch, master has been updated
       via  e184b18f5796f9fd5d23410b7dc68d298e609933 (commit)
      from  198db03ee8b70159f27f1b3033b2ad1802a138ed (commit)

Summary of changes:
 src/plugins/managesieve/sieve_prefs.c |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit e184b18f5796f9fd5d23410b7dc68d298e609933
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Wed Jul 1 18:45:36 2015 +0200

    Managesieve: Fix parsing config string on Windows
    
    Windows sscanf() does not understand the %ms format yet, so we
    have to do the allocation of target buffer ourselves before
    calling sscanf(), and copy the host string to config->host.
    
    Also fix some off-by-one bugs in other sscanf() parameters - the
    field width format modifier does not include trailing NUL byte,
    which is added.

diff --git a/src/plugins/managesieve/sieve_prefs.c b/src/plugins/managesieve/sieve_prefs.c
index 69d8aa4..0bd3e41 100644
--- a/src/plugins/managesieve/sieve_prefs.c
+++ b/src/plugins/managesieve/sieve_prefs.c
@@ -151,6 +151,7 @@ static void sieve_prefs_account_create_widget_func(PrefsPage *_page,
 	gtk_size_group_add_widget(size_group, host_checkbtn);
 
 	host_entry = gtk_entry_new();
+	gtk_entry_set_max_length(GTK_ENTRY(host_entry), 255);
 	gtk_widget_show (host_entry);
 	gtk_box_pack_start (GTK_BOX (hbox), host_entry, TRUE, TRUE, 0);
 	SET_TOGGLE_SENSITIVITY (host_checkbtn, host_entry);
@@ -419,6 +420,13 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 	gchar enc_userid[256], enc_passwd[256];
 	gchar enable, use_host, use_port;
 	gsize len;
+#ifdef G_OS_WIN32
+	/* Windows sscanf() does not understand the %ms format yet, so we
+	 * have to do the allocation of target buffer ourselves before
+	 * calling sscanf(), and copy the host string to config->host.
+	 */
+	gchar tmphost[256];
+#endif
 
 	config = g_new0(SieveAccountConfig, 1);
 
@@ -437,10 +445,17 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 	if (confstr == NULL)
 		return config;
 
-
-	sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %256s %256s",
+#ifdef G_OS_WIN32
+	sscanf(confstr, "%c%c %255s %c%hu %hhu %hhu %hhu %255s %255s",
+#else
+	sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %255s %255s",
+#endif
 			&enable, &use_host,
+#ifdef G_OS_WIN32
+			tmphost,
+#else
 			&config->host,
+#endif
 			&use_port, &config->port,
 			(char *)&config->tls_type,
 			(char *)&config->auth,
@@ -448,6 +463,10 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
 			enc_userid,
 			enc_passwd);
 
+#ifdef G_OS_WIN32
+	config->host = g_strndup(tmphost, 255);
+#endif
+
 	config->enable = enable == 'y';
 	config->use_host = use_host == 'y';
 	config->use_port = use_port == 'y';

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list