[Commits] [SCM] claws branch, master, updated. 3.17.3-26-g54e5f17

wwp at claws-mail.org wwp at claws-mail.org
Thu Jan 3 10:39:18 CET 2019


The branch, master has been updated
       via  54e5f174d6651258b9e04617951c9dcba51f6467 (commit)
      from  9bed4f7d3e73acd4e6dbc5f40af09b93f60c829e (commit)

Summary of changes:
 src/addr_compl.c                          |   10 +++++++--
 src/mimeview.c                            |   17 ++++++++++-----
 src/plugins/libravatar/libravatar_image.c |   34 +++++++++++++++++------------
 src/plugins/spam_report/spam_report.c     |    9 ++++++--
 4 files changed, 46 insertions(+), 24 deletions(-)


- Log -----------------------------------------------------------------
commit 54e5f174d6651258b9e04617951c9dcba51f6467
Author: wwp <subscript at free.fr>
Date:   Thu Jan 3 10:36:37 2019 +0100

    Fix few (possible) crashes due to missing return code checks (patch
    by Zhouyang, with few modifications).
    
    Fixes bug #3977: Fix crshes when some external APIs fail

diff --git a/src/addr_compl.c b/src/addr_compl.c
index cb842ab..e0e9373 100644
--- a/src/addr_compl.c
+++ b/src/addr_compl.c
@@ -945,6 +945,7 @@ static void completion_window_advance_selection(GtkTreeView *list_view, gboolean
  */
 static void addrcompl_resize_window( CompletionWindow *cw ) {
 	GtkRequisition r;
+	GdkGrabStatus status;
 	gint x, y, width, height, depth;
 
 	/* Get current geometry of window */
@@ -963,7 +964,9 @@ static void addrcompl_resize_window( CompletionWindow *cw ) {
 			 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
 			 GDK_BUTTON_RELEASE_MASK,
 			 NULL, NULL, GDK_CURRENT_TIME);
-	gdk_keyboard_grab(gtk_widget_get_window(cw->window), FALSE, GDK_CURRENT_TIME);
+	status = gdk_keyboard_grab(gtk_widget_get_window(cw->window), FALSE, GDK_CURRENT_TIME);
+	if (status != GDK_GRAB_SUCCESS)
+		g_warning("gdk_keyboard_grab failed with status %d", status);
 	gtk_grab_add(cw->window);
 
 }
@@ -1443,6 +1446,7 @@ static void address_completion_create_completion_window( GtkEntry *entry_ )
 {
 	gint x, y, height, width, depth;
 	GtkWidget *scroll, *list_view;
+	GdkGrabStatus status;
 	GtkRequisition r;
 	GtkWidget *window;
 	GtkWidget *entry = GTK_WIDGET(entry_);
@@ -1503,7 +1507,9 @@ static void address_completion_create_completion_window( GtkEntry *entry_ )
 			 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
 			 GDK_BUTTON_RELEASE_MASK,
 			 NULL, NULL, GDK_CURRENT_TIME);
-	gdk_keyboard_grab(gtk_widget_get_window(window), FALSE, GDK_CURRENT_TIME);
+	status = gdk_keyboard_grab(gtk_widget_get_window(window), FALSE, GDK_CURRENT_TIME);
+	if (status != GDK_GRAB_SUCCESS)
+		g_warning("gdk_keyboard_grab failed with status %d", status);
 	gtk_grab_add( window );
 }
 
diff --git a/src/mimeview.c b/src/mimeview.c
index daaac32..b697d52 100644
--- a/src/mimeview.c
+++ b/src/mimeview.c
@@ -1275,7 +1275,7 @@ static void mimeview_check_sig_in_thread(MimeView *mimeview)
 			mimeview_check_sig_worker_thread, 
 			mimeview) != 0) {
 		/* arh. We'll do it synchronously. */
-		g_warning("can't create thread");
+		g_warning("can't create checked thread");
 		g_free(mimeview->check_data);
 		mimeview->check_data = NULL;
 		return;
@@ -1285,12 +1285,17 @@ static void mimeview_check_sig_in_thread(MimeView *mimeview)
 	}
 
 	/* create the killer thread */
-	pthread_create(&th2, &detach2, 
+	if (pthread_create(&th2, &detach2, 
 			mimeview_check_sig_cancel_thread, 
-			mimeview);
-
-	mimeview->check_data->cancel_th = th2;
-	mimeview->check_data->cancel_th_init = TRUE;
+			mimeview) != 0) {
+		g_warning("can't create killer thread");
+		g_free(mimeview->check_data);
+		mimeview->check_data = NULL;
+		return;
+	} else {
+		mimeview->check_data->cancel_th = th2;
+		mimeview->check_data->cancel_th_init = TRUE;
+	}
 }
 #endif
 
diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c
index 9a0338b..057569a 100644
--- a/src/plugins/libravatar/libravatar_image.c
+++ b/src/plugins/libravatar/libravatar_image.c
@@ -72,6 +72,7 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha
 	GdkPixbuf *image = NULL;
 	FILE *file;
 	CURL *curl;
+	CURLcode res;
 	long filesize;
 
 	file = claws_fopen(filename, "wb");
@@ -105,21 +106,26 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha
 	}
 	curl_easy_setopt(curl, CURLOPT_FILE, file);
 	debug_print("retrieving URL to file: %s -> %s\n", url, filename);
-	curl_easy_perform(curl);
-	filesize = ftell(file);
-	claws_safe_fclose(file);
-	if (filesize < MIN_PNG_SIZE)
-		debug_print("not enough data for an avatar image: %ld bytes\n", filesize);
-	else
-		image = image_pixbuf_from_filename(filename);
-
-	if (!libravatarprefs.cache_icons || filesize == 0) {
-		if (g_unlink(filename) < 0)
-			g_warning("failed to delete cache file '%s'", filename);
-	}
+	res = curl_easy_perform(curl);
+	if (res != CURLE_OK) {
+		debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res));
+		claws_safe_fclose(file);
+	} else {
+		filesize = ftell(file);
+		claws_safe_fclose(file);
+		if (filesize < MIN_PNG_SIZE)
+			debug_print("not enough data for an avatar image: %ld bytes\n", filesize);
+		else
+			image = image_pixbuf_from_filename(filename);
+
+		if (!libravatarprefs.cache_icons || filesize == 0) {
+			if (g_unlink(filename) < 0)
+				g_warning("failed to delete cache file '%s'", filename);
+		}
 
-	if (filesize == 0)
-		missing_add_md5(libravatarmisses, md5);
+		if (filesize == 0)
+			missing_add_md5(libravatarmisses, md5);
+	}
 
 	curl_easy_cleanup(curl);
 
diff --git a/src/plugins/spam_report/spam_report.c b/src/plugins/spam_report/spam_report.c
index 21c96cc..50f0c10 100644
--- a/src/plugins/spam_report/spam_report.c
+++ b/src/plugins/spam_report/spam_report.c
@@ -198,6 +198,7 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
 	gchar *reqbody = NULL, *tmp = NULL, *auth = NULL, *b64 = NULL, *geturl = NULL;
 	size_t len_contents;
 	CURL *curl;
+	CURLcode res;
 	long response;
 	struct CurlReadWrite chunk;
 
@@ -239,7 +240,9 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
 			curl_easy_setopt(curl, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs);
 			curl_easy_setopt(curl, CURLOPT_USERAGENT,
                 		SPAM_REPORT_USERAGENT "(" PLUGINS_URI ")");
-			curl_easy_perform(curl);
+			res = curl_easy_perform(curl);
+			if (res != CURLE_OK)
+				debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res));
 			curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
 			curl_easy_cleanup(curl);
 			spamreport_http_response_log(intf->url, response);
@@ -261,7 +264,9 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
                 		SPAM_REPORT_USERAGENT "(" PLUGINS_URI ")");
         	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writefunction_cb);
 	        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
-        	curl_easy_perform(curl);
+		res = curl_easy_perform(curl);
+		if (res != CURLE_OK)
+			debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res));
 		curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
 	        curl_easy_cleanup(curl);
 		spamreport_http_response_log(geturl, response);

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list