Fix some CWE-252 coverity warnings release-2.x.y

Tue, 06 May 2014 19:38:50 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 06 May 2014 19:38:50 +0200
branch
release-2.x.y
changeset 35991
e6937e52930b
parent 35990
dcbaf8e5e624
child 35992
34a67264df99

Fix some CWE-252 coverity warnings

finch/finch.c file | annotate | diff | comparison | revisions
finch/gntprefs.c file | annotate | diff | comparison | revisions
finch/gntrequest.c file | annotate | diff | comparison | revisions
finch/libgnt/gntbox.c file | annotate | diff | comparison | revisions
finch/libgnt/gntcheckbox.c file | annotate | diff | comparison | revisions
finch/libgnt/gntcombobox.c file | annotate | diff | comparison | revisions
finch/libgnt/gntentry.c file | annotate | diff | comparison | revisions
finch/libgnt/gnttextview.c file | annotate | diff | comparison | revisions
finch/libgnt/gntwm.c file | annotate | diff | comparison | revisions
finch/libgnt/wms/irssi.c file | annotate | diff | comparison | revisions
libpurple/ft.c file | annotate | diff | comparison | revisions
libpurple/log.c file | annotate | diff | comparison | revisions
libpurple/network.c file | annotate | diff | comparison | revisions
libpurple/plugins/log_reader.c file | annotate | diff | comparison | revisions
libpurple/protocols/bonjour/bonjour_ft.c file | annotate | diff | comparison | revisions
libpurple/protocols/bonjour/jabber.c file | annotate | diff | comparison | revisions
libpurple/protocols/irc/dcc_send.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/chat.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/si.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/peer.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/userinfo.c file | annotate | diff | comparison | revisions
libpurple/protocols/simple/simple.c file | annotate | diff | comparison | revisions
libpurple/protocols/yahoo/util.c file | annotate | diff | comparison | revisions
libpurple/protocols/zephyr/ZOpenPort.c file | annotate | diff | comparison | revisions
libpurple/proxy.c file | annotate | diff | comparison | revisions
libpurple/stun.c file | annotate | diff | comparison | revisions
libpurple/util.c file | annotate | diff | comparison | revisions
pidgin/gtkmain.c file | annotate | diff | comparison | revisions
pidgin/gtkprefs.c file | annotate | diff | comparison | revisions
pidgin/gtksession.c file | annotate | diff | comparison | revisions
pidgin/gtkthemes.c file | annotate | diff | comparison | revisions
pidgin/plugins/spellchk.c file | annotate | diff | comparison | revisions
--- a/finch/finch.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/finch.c	Tue May 06 19:38:50 2014 +0200
@@ -379,8 +379,10 @@
 	purple_idle_set_ui_ops(finch_idle_get_ui_ops());
 
 	path = g_build_filename(purple_user_dir(), "plugins", NULL);
-	if (!g_stat(path, &st))
-		g_mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR);
+	if (!g_stat(path, &st)) {
+		if (g_mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
+			fprintf(stderr, "Couldn't create plugins dir\n");
+	}
 	purple_plugins_add_search_path(path);
 	g_free(path);
 
--- a/finch/gntprefs.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/gntprefs.c	Tue May 06 19:38:50 2014 +0200
@@ -155,12 +155,14 @@
 			switch (prefs->type)
 			{
 				case PURPLE_PREF_BOOLEAN:
-					sscanf(iter->data, "%d", &idata);
+					if (sscanf(iter->data, "%d", &idata) != 1)
+						idata = FALSE;
 					if (purple_prefs_get_bool(prefs->pref) == idata)
 						select = TRUE;
 					break;
 				case PURPLE_PREF_INT:
-					sscanf(iter->data, "%d", &idata);
+					if (sscanf(iter->data, "%d", &idata) != 1)
+						idata = 0;
 					if (purple_prefs_get_int(prefs->pref) == idata)
 						select = TRUE;
 					break;
--- a/finch/gntrequest.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/gntrequest.c	Tue May 06 19:38:50 2014 +0200
@@ -854,8 +854,11 @@
 				case PURPLE_PREF_INT:
 				{
 					long int tmp = GPOINTER_TO_INT(val);
-					if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */
-						sscanf(val, "%ld", &tmp);
+					if (type == PURPLE_REQUEST_FIELD_LIST) {
+						/* Lists always return string */
+						if (sscanf(val, "%ld", &tmp) != 1)
+							tmp = 0;
+					}
 					purple_prefs_set_int(id, (gint)tmp);
 					break;
 				}
--- a/finch/libgnt/gntbox.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gntbox.c	Tue May 06 19:38:50 2014 +0200
@@ -232,8 +232,8 @@
 				h = maxh;
 		}
 
-		gnt_widget_confirm_size(wid, w, h);
-		gnt_widget_set_size(wid, w, h);
+		if (gnt_widget_confirm_size(wid, w, h))
+			gnt_widget_set_size(wid, w, h);
 	}
 
 	reposition_children(widget);
--- a/finch/libgnt/gntcheckbox.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gntcheckbox.c	Tue May 06 19:38:50 2014 +0200
@@ -52,7 +52,7 @@
 
 	wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
 	mvwaddstr(widget->window, 0, 4, C_(GNT_BUTTON(cb)->priv->text));
-	wmove(widget->window, 0, 1);
+	(void)wmove(widget->window, 0, 1);
 
 	GNTDEBUG;
 }
--- a/finch/libgnt/gntcombobox.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gntcombobox.c	Tue May 06 19:38:50 2014 +0200
@@ -96,7 +96,7 @@
 	whline(widget->window, ' ' | gnt_color_pair(type), widget->priv.width - 4 - len);
 	mvwaddch(widget->window, 1, widget->priv.width - 3, ACS_VLINE | gnt_color_pair(GNT_COLOR_NORMAL));
 	mvwaddch(widget->window, 1, widget->priv.width - 2, ACS_DARROW | gnt_color_pair(GNT_COLOR_NORMAL));
-	wmove(widget->window, 1, 1);
+	(void)wmove(widget->window, 1, 1);
 
 	g_free(text);
 	GNTDEBUG;
--- a/finch/libgnt/gntentry.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gntentry.c	Tue May 06 19:38:50 2014 +0200
@@ -299,7 +299,7 @@
 	curpos = gnt_util_onscreen_width(entry->scroll, entry->cursor);
 	if (focus)
 		mvwchgat(widget->window, 0, curpos, 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
-	wmove(widget->window, 0, curpos);
+	(void)wmove(widget->window, 0, curpos);
 
 	GNTDEBUG;
 }
--- a/finch/libgnt/gnttextview.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gnttextview.c	Tue May 06 19:38:50 2014 +0200
@@ -106,7 +106,7 @@
 		GList *iter;
 		GntTextLine *line = lines->data;
 
-		wmove(widget->window, widget->priv.height - 1 - i - comp, 0);
+		(void)wmove(widget->window, widget->priv.height - 1 - i - comp, 0);
 
 		for (iter = line->segments; iter; iter = iter->next)
 		{
--- a/finch/libgnt/gntwm.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/gntwm.c	Tue May 06 19:38:50 2014 +0200
@@ -148,7 +148,7 @@
 			int curx = active->priv.x + getcurx(active->window);
 			int cury = active->priv.y + getcury(active->window);
 			if (wmove(node->window, cury - widget->priv.y, curx - widget->priv.x) != OK)
-				wmove(node->window, 0, 0);
+				(void)wmove(node->window, 0, 0);
 		}
 	}
 }
@@ -1850,6 +1850,8 @@
 
 		maxx = getmaxx(stdscr);
 		maxy = getmaxy(stdscr) - 1;              /* room for the taskbar */
+		maxx = MAX(0, maxx);
+		maxy = MAX(0, maxy);
 
 		x = MAX(0, x);
 		y = MAX(0, y);
--- a/finch/libgnt/wms/irssi.c	Tue May 06 18:28:56 2014 +0200
+++ b/finch/libgnt/wms/irssi.c	Tue May 06 19:38:50 2014 +0200
@@ -215,7 +215,7 @@
 	getyx(node->window, y, x);
 	wbkgdset(node->window, '\0' | COLOR_PAIR(gnt_widget_has_focus(node->me) ? GNT_COLOR_TITLE : GNT_COLOR_TITLE_D));
 	mvwaddstr(node->window, 0, 0, title);
-	wmove(node->window, y, x);
+	(void)wmove(node->window, y, x);
 	if (!gnt_is_refugee()) {
 		update_panels();
 		doupdate();
--- a/libpurple/ft.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/ft.c	Tue May 06 19:38:50 2014 +0200
@@ -1307,7 +1307,12 @@
 			return;
 		}
 
-		fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET);
+		if (fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET) != 0) {
+			purple_debug_error("xfer", "couldn't seek\n");
+			purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer));
+			purple_xfer_cancel_local(xfer);
+			return;
+		}
 	}
 
 	if (xfer->fd != -1)
--- a/libpurple/log.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/log.c	Tue May 06 19:38:50 2014 +0200
@@ -1837,8 +1837,12 @@
 
 			g_snprintf(convostart, length, "%s", temp);
 			memset(&tm, 0, sizeof(tm));
-			sscanf(convostart, "%*s %3s %d %d:%d:%d %d",
-			       month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
+			if (sscanf(convostart, "%*s %3s %d %d:%d:%d %d", month,
+				&tm.tm_mday, &tm.tm_hour, &tm.tm_min,
+				&tm.tm_sec, &tm.tm_year) != 6)
+			{
+				purple_debug_warning("log", "invalid date format\n");
+			}
 			/* Ugly hack, in case current locale is not English */
 			if (purple_strequal(month, "Jan")) {
 				tm.tm_mon= 0;
@@ -1943,8 +1947,10 @@
 	const char *path = purple_stringref_value(data->pathref);
 	FILE *file = g_fopen(path, "rb");
 	char *read = g_malloc(data->length + 1);
-	fseek(file, data->offset, SEEK_SET);
-	result = fread(read, data->length, 1, file);
+	if (fseek(file, data->offset, SEEK_SET) != 0)
+		result = 0;
+	else
+		result = fread(read, data->length, 1, file);
 	if (result != 1)
 		purple_debug_error("log", "Unable to read from log file: %s\n", path);
 	fclose(file);
--- a/libpurple/network.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/network.c	Tue May 06 19:38:50 2014 +0200
@@ -179,7 +179,7 @@
 	ifc.ifc_req = (struct ifreq *)buffer;
 	ioctl(source, SIOCGIFCONF, &ifc);
 
-	if (fd < 0)
+	if (fd < 0 && source >= 0)
 		close(source);
 
 	tmp = buffer;
@@ -489,7 +489,8 @@
 	flags = fcntl(listenfd, F_GETFL);
 	fcntl(listenfd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(listenfd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(listenfd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("network", "couldn't set FD_CLOEXEC\n");
 #endif
 	actual_port = purple_network_get_port_from_fd(listenfd);
 
--- a/libpurple/plugins/log_reader.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/plugins/log_reader.c	Tue May 06 19:38:50 2014 +0200
@@ -1425,7 +1425,8 @@
 	read = g_malloc(data->length + 2);
 
 	file = g_fopen(data->path, "rb");
-	fseek(file, data->offset, SEEK_SET);
+	if (fseek(file, data->offset, SEEK_SET) != 0)
+		g_return_val_if_reached(g_strdup(""));
 	data->length = fread(read, 1, data->length, file);
 	fclose(file);
 
@@ -1946,7 +1947,8 @@
 
 	contents = g_malloc(data->length + 2);
 
-	fseek(file, data->offset, SEEK_SET);
+	if (fseek(file, data->offset, SEEK_SET) != 0)
+		g_return_val_if_reached(g_strdup(""));
 	data->length = fread(contents, 1, data->length, file);
 	fclose(file);
 
@@ -2329,7 +2331,8 @@
 	file = g_fopen(data->path, "rb");
 	g_return_val_if_fail(file != NULL, g_strdup(""));
 
-	fseek(file, data->offset, SEEK_SET);
+	if (fseek(file, data->offset, SEEK_SET) != 0)
+		g_return_val_if_reached(g_strdup(""));
 	data->length = fread(contents, 1, data->length, file);
 	fclose(file);
 
--- a/libpurple/protocols/bonjour/bonjour_ft.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/bonjour/bonjour_ft.c	Tue May 06 19:38:50 2014 +0200
@@ -815,7 +815,8 @@
 			flags = fcntl(acceptfd, F_GETFL);
 			fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-			fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
+			if (fcntl(acceptfd, F_SETFD, FD_CLOEXEC) != 0)
+				purple_debug_warning("bonjour", "couldn't set FD_CLOEXEC\n");
 #endif
 
 			purple_input_remove(xfer->watcher);
--- a/libpurple/protocols/bonjour/jabber.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/bonjour/jabber.c	Tue May 06 19:38:50 2014 +0200
@@ -656,7 +656,8 @@
 	flags = fcntl(client_socket, F_GETFL);
 	fcntl(client_socket, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(client_socket, F_SETFD, FD_CLOEXEC);
+	if (fcntl(client_socket, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("bonjour", "jabber: couldn't set FD_CLOEXEC\n");
 #endif
 
 	/* Look for the buddy that has opened the conversation and fill information */
@@ -775,7 +776,10 @@
 		struct sockaddr_in6 addr6;
 #ifdef IPV6_V6ONLY
 		int on = 1;
-		setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+		if (setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) {
+			purple_debug_error("bonjour", "couldn't force IPv6\n");
+			return -1;
+		}
 #endif
 	        memset(&addr6, 0, sizeof(addr6));
 		addr6.sin6_family = AF_INET6;
@@ -1168,8 +1172,14 @@
 		/* Close the socket and remove the watcher */
 		if (bconv->socket >= 0) {
 			/* Send the end of the stream to the other end of the conversation */
-			if (bconv->sent_stream_start == FULLY_SENT)
-				send(bconv->socket, STREAM_END, strlen(STREAM_END), 0);
+			if (bconv->sent_stream_start == FULLY_SENT) {
+				size_t len = strlen(STREAM_END);
+				if (send(bconv->socket, STREAM_END, len, 0) != len) {
+					purple_debug_error("bonjour",
+						"bonjour_jabber_close_conversation: "
+						"couldn't send data\n");
+				}
+			}
 			/* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */
 			close(bconv->socket);
 		}
--- a/libpurple/protocols/irc/dcc_send.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/irc/dcc_send.c	Tue May 06 19:38:50 2014 +0200
@@ -265,7 +265,8 @@
 	flags = fcntl(conn, F_GETFL);
 	fcntl(conn, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(conn, F_SETFD, FD_CLOEXEC);
+	if (fcntl(conn, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("irc", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	xd->inpa = purple_input_add(conn, PURPLE_INPUT_READ, irc_dccsend_send_read, xfer);
--- a/libpurple/protocols/jabber/chat.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/jabber/chat.c	Tue May 06 19:38:50 2014 +0200
@@ -1275,7 +1275,8 @@
 	JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
 
 	if (jbr) {
-		*all_support &= jabber_resource_has_capability(jbr, cap);
+		if (*all_support && jabber_resource_has_capability(jbr, cap))
+			*all_support = TRUE;
 	} else {
 		*all_support = FALSE;
 	}
--- a/libpurple/protocols/jabber/si.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/jabber/si.c	Tue May 06 19:38:50 2014 +0200
@@ -701,7 +701,8 @@
 	flags = fcntl(acceptfd, F_GETFL);
 	fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(acceptfd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("jabber", "si: couldn't set FD_CLOEXEC\n");
 #endif
 
 	xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ,
--- a/libpurple/protocols/oscar/peer.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/oscar/peer.c	Tue May 06 19:38:50 2014 +0200
@@ -633,7 +633,8 @@
 	flags = fcntl(conn->fd, F_GETFL);
 	fcntl(conn->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(conn->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(conn->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("oscar", "peer: couldn't set FD_CLOEXEC\n");
 #endif
 
 	purple_input_remove(conn->watcher_incoming);
--- a/libpurple/protocols/oscar/userinfo.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/oscar/userinfo.c	Tue May 06 19:38:50 2014 +0200
@@ -371,7 +371,8 @@
 	purple_notify_user_info_add_pair(user_info, NULL, buf);
 	purple_notify_userinfo(od->gc, buddy, user_info, NULL, NULL);
 	purple_notify_user_info_destroy(user_info);
-	purple_conv_present_error(buddy, purple_connection_get_account(od->gc), buf);
+	if (!purple_conv_present_error(buddy, purple_connection_get_account(od->gc), buf))
+		purple_notify_error(od->gc, NULL, buf, NULL);
 	g_free(buf);
 }
 
--- a/libpurple/protocols/simple/simple.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/simple/simple.c	Tue May 06 19:38:50 2014 +0200
@@ -72,7 +72,12 @@
 			 remain in the NAT table */
 		gchar buf[2] = {0, 0};
 		purple_debug_info("simple", "sending keep alive\n");
-		sendto(sip->fd, buf, 1, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in));
+		if (sendto(sip->fd, buf, 1, 0,
+			(struct sockaddr*)&sip->serveraddr,
+			sizeof(struct sockaddr_in)) != 1)
+		{
+			purple_debug_error("simple", "failed sending keep alive\n");
+		}
 	}
 	return;
 }
@@ -1723,7 +1728,8 @@
 	flags = fcntl(newfd, F_GETFL);
 	fcntl(newfd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(newfd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(newfd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("simple", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	conn = connection_create(sip, newfd);
--- a/libpurple/protocols/yahoo/util.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/yahoo/util.c	Tue May 06 19:38:50 2014 +0200
@@ -460,7 +460,8 @@
 		GData *attributes;
 		char *fontsize = NULL;
 
-		purple_markup_find_tag(tag_name, tag, &start, &end, &attributes);
+		if (!purple_markup_find_tag(tag_name, tag, &start, &end, &attributes))
+			g_return_if_reached();
 		*cur = xmlnode_new_child(*cur, tag_name);
 
 		if (is_font_tag) {
@@ -738,7 +739,8 @@
 	gboolean needendtag;
 	GString *tmp;
 
-	purple_markup_find_tag(tag_name, tag, &start, &end, &attributes);
+	if (!purple_markup_find_tag(tag_name, tag, &start, &end, &attributes))
+		g_return_if_reached();
 
 	needendtag = FALSE;
 	tmp = g_string_new(NULL);
@@ -864,7 +866,16 @@
 					 */
 
 					/* Append the URL */
-					purple_markup_find_tag(tag_name, tag, &start, &end, &attributes);
+					if (!purple_markup_find_tag(tag_name,
+						tag, &start, &end, &attributes))
+					{
+						g_warn_if_reached();
+						i = j;
+						g_free(tag);
+						g_free(tag_name);
+						break;
+					}
+
 					attribute = g_datalist_get_data(&attributes, "href");
 					if (attribute != NULL) {
 						if (purple_str_has_prefix(attribute, "mailto:"))
--- a/libpurple/protocols/zephyr/ZOpenPort.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/protocols/zephyr/ZOpenPort.c	Tue May 06 19:38:50 2014 +0200
@@ -30,12 +30,15 @@
     }
 
 #ifdef SO_BSDCOMPAT
-    {
-      int on = 1;
+	{
+		int on = 1;
 
-      setsockopt(__Zephyr_fd, SOL_SOCKET, SO_BSDCOMPAT, (char *)&on,
-		 sizeof(on));
-    }
+		if (setsockopt(__Zephyr_fd, SOL_SOCKET, SO_BSDCOMPAT,
+			(char *)&on, sizeof(on)) != 0)
+		{
+			purple_debug_warning("zephyr", "couldn't setsockopt\n");
+		}
+	}
 #endif
 
     bindin.sin_family = AF_INET;
--- a/libpurple/proxy.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/proxy.c	Tue May 06 19:38:50 2014 +0200
@@ -758,7 +758,8 @@
 	flags = fcntl(connect_data->fd, F_GETFL);
 	fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("proxy", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	if (connect(connect_data->fd, addr, addrlen) != 0)
@@ -820,7 +821,8 @@
 	flags = fcntl(connect_data->fd, F_GETFL);
 	fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("proxy", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	if (connect(connect_data->fd, addr, addrlen) != 0)
@@ -1274,7 +1276,8 @@
 	flags = fcntl(connect_data->fd, F_GETFL);
 	fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("proxy", "couldn't FD_CLOEXEC\n");
 #endif
 
 	if (connect(connect_data->fd, addr, addrlen) != 0) {
@@ -1468,7 +1471,8 @@
 	flags = fcntl(connect_data->fd, F_GETFL);
 	fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("proxy", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	if (connect(connect_data->fd, addr, addrlen) != 0)
@@ -2128,7 +2132,8 @@
 	flags = fcntl(connect_data->fd, F_GETFL);
 	fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK);
 #ifndef _WIN32
-	fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC);
+	if (fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC) != 0)
+		purple_debug_warning("proxy", "couldn't set FD_CLOEXEC\n");
 #endif
 
 	if (connect(connect_data->fd, addr, addrlen) != 0)
--- a/libpurple/stun.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/stun.c	Tue May 06 19:38:50 2014 +0200
@@ -136,8 +136,13 @@
 	}
 	purple_debug_info("stun", "request timed out, retrying.\n");
 	sc->retry++;
-	sendto(sc->fd, sc->packet, sc->packetsize, 0,
-		(struct sockaddr *)&(sc->addr), sizeof(struct sockaddr_in));
+	if (sendto(sc->fd, sc->packet, sc->packetsize, 0,
+		(struct sockaddr *)&(sc->addr), sizeof(struct sockaddr_in)) !=
+		sc->packetsize)
+	{
+		purple_debug_warning("stun", "sendto failed\n");
+		return FALSE;
+	}
 	return TRUE;
 }
 
--- a/libpurple/util.c	Tue May 06 18:28:56 2014 +0200
+++ b/libpurple/util.c	Tue May 06 19:38:50 2014 +0200
@@ -3738,7 +3738,10 @@
 
 	p = find_header_content(data, data_len, "\nContent-Length: ");
 	if (p) {
-		sscanf(p, "%" G_GSIZE_FORMAT, &content_len);
+		if (sscanf(p, "%" G_GSIZE_FORMAT, &content_len) != 1) {
+			purple_debug_warning("util", "invalid number format\n");
+			content_len = 0;
+		}
 		purple_debug_misc("util", "parsed %" G_GSIZE_FORMAT "\n", content_len);
 	}
 
@@ -4583,7 +4586,7 @@
 	workstr = g_string_sized_new(strlen(str));
 
 	do {
-		g_utf8_validate(str, -1, &end);
+		(void)g_utf8_validate(str, -1, &end);
 		workstr = g_string_append_len(workstr, str, end - str);
 		str = end;
 		if (*str == '\0')
--- a/pidgin/gtkmain.c	Tue May 06 18:28:56 2014 +0200
+++ b/pidgin/gtkmain.c	Tue May 06 19:38:50 2014 +0200
@@ -808,8 +808,10 @@
 	 * in user's home directory.
 	 */
 	search_path = g_build_filename(purple_user_dir(), "plugins", NULL);
-	if (!g_stat(search_path, &st))
-		g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR);
+	if (!g_stat(search_path, &st)) {
+		if (!g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR))
+			fprintf(stderr, "Couldn't create plugins dir\n");
+	}
 	purple_plugins_add_search_path(search_path);
 	g_free(search_path);
 	purple_plugins_add_search_path(LIBDIR);
--- a/pidgin/gtkprefs.c	Tue May 06 18:28:56 2014 +0200
+++ b/pidgin/gtkprefs.c	Tue May 06 19:38:50 2014 +0200
@@ -777,7 +777,10 @@
 
 				prefs_themes_refresh();
 			} else {
-				g_remove(temp_path);
+				if (g_remove(temp_path) != 0) {
+					purple_debug_error("gtkprefs",
+						"couldn't remove temp path\n");
+				}
 				purple_notify_error(NULL, NULL, _("Theme failed to load."), NULL);
 			}
 		} else {
--- a/pidgin/gtksession.c	Tue May 06 18:28:56 2014 +0200
+++ b/pidgin/gtksession.c	Tue May 06 19:38:50 2014 +0200
@@ -86,7 +86,8 @@
 				   "Handling new ICE connection... \n");
 
 		/* ensure ICE connection is not passed to child processes */
-		fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC);
+		if (fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC) != 0)
+			purple_debug_warning("gtksession", "couldn't set FD_CLOEXEC\n");
 
 		conninfo = g_new(struct ice_connection_info, 1);
 		conninfo->connection = connection;
--- a/pidgin/gtkthemes.c	Tue May 06 18:28:56 2014 +0200
+++ b/pidgin/gtkthemes.c	Tue May 06 19:38:50 2014 +0200
@@ -410,7 +410,10 @@
 			}
 			g_dir_close(dir);
 		} else if (l == 1) {
-			g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
+			if (g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
+				purple_debug_error("gtkthemes",
+					"couldn't create smileys dir\n");
+			}
 		}
 		g_free(probedirs[l]);
 	}
--- a/pidgin/plugins/spellchk.c	Tue May 06 18:28:56 2014 +0200
+++ b/pidgin/plugins/spellchk.c	Tue May 06 19:38:50 2014 +0200
@@ -1781,12 +1781,11 @@
 	gboolean case_sensitive = FALSE;
 
 	buf = g_build_filename(purple_user_dir(), "dict", NULL);
-	g_file_get_contents(buf, &ibuf, &size, NULL);
-	g_free(buf);
-	if (!ibuf) {
+	if (g_file_get_contents(buf, &ibuf, &size, NULL) && ibuf) {
 		ibuf = g_strdup(defaultconf);
 		size = strlen(defaultconf);
 	}
+	g_free(buf);
 
 	model = gtk_list_store_new((gint)N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
 	hashes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

mercurial