changeset 29752:e59f29a9dbf1

merge of 'de5074f5f3785a3e757b9ab4ed946a01ddc69944' and 'e8d0f65afa1697a579f40a67aa98f8a8fa4523f0'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 17 Apr 2010 22:22:52 +0000
parents 2b294edceaed (current diff) 211afed0548b (diff)
children 378cceb9131d
files
diffstat 4 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 17 22:22:21 2010 +0000
+++ b/ChangeLog	Sat Apr 17 22:22:52 2010 +0000
@@ -45,6 +45,8 @@
 	  buddy icons.
 	* The 'Message Timestamp Formats' plugin allows changing the timestamp
 	  format from the timestamps' context menu in conversation log.
+	* Fix pastes from Chrome (rich-text pastes and probably URLs
+	  having garbage appended to them)
 
 	Bonjour:
 	* Added support for IPv6. (Thanks to T_X for testing)
--- a/libpurple/protocols/jabber/jabber.c	Sat Apr 17 22:22:21 2010 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Apr 17 22:22:52 2010 +0000
@@ -1540,7 +1540,8 @@
 	g_free(js->avatar_hash);
 	g_free(js->caps_hash);
 
-	purple_circ_buffer_destroy(js->write_buffer);
+	if (js->write_buffer)
+		purple_circ_buffer_destroy(js->write_buffer);
 	if(js->writeh)
 		purple_input_remove(js->writeh);
 	if (js->auth_mech && js->auth_mech->dispose)
--- a/libpurple/util.c	Sat Apr 17 22:22:21 2010 +0000
+++ b/libpurple/util.c	Sat Apr 17 22:22:52 2010 +0000
@@ -2969,33 +2969,38 @@
 #endif
 }
 
+typedef union purple_sockaddr {
+	struct sockaddr         sa;
+	struct sockaddr_in      sa_in;
+#if defined(AF_INET6)
+	struct sockaddr_in6     sa_in6;
+#endif
+	struct sockaddr_storage sa_stor;
+} PurpleSockaddr;
+
 char *
 purple_fd_get_ip(int fd)
 {
-	struct sockaddr_storage addr;
+	PurpleSockaddr addr;
 	socklen_t namelen = sizeof(addr);
 	int family;
 
 	g_return_val_if_fail(fd != 0, NULL);
 
-	if (getsockname(fd, (struct sockaddr *)&addr, &namelen))
+	if (getsockname(fd, &(addr.sa), &namelen))
 		return NULL;
 
-	family = ((struct sockaddr *)&addr)->sa_family;
+	family = addr.sa.sa_family;
 
 	if (family == AF_INET) {
-		struct sockaddr_in *ipv4 = (struct sockaddr_in *)&addr;
-		struct in_addr addr = ipv4->sin_addr;
-		return g_strdup(inet_ntoa(addr));
+		return g_strdup(inet_ntoa(addr.sa_in.sin_addr));
 	}
 #if defined(AF_INET6) && defined(HAVE_INET_NTOP)
 	else if (family == AF_INET6) {
-		struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&addr;
-		struct in6_addr addr = ipv6->sin6_addr;
 		char host[INET6_ADDRSTRLEN];
 		const char *tmp;
 
-		tmp = inet_ntop(family, &addr, host, sizeof(host));
+		tmp = inet_ntop(family, &(addr.sa_in6.sin6_addr), host, sizeof(host));
 		return g_strdup(tmp);
 	}
 #endif
@@ -3006,22 +3011,22 @@
 int
 purple_socket_get_family(int fd)
 {
-	struct sockaddr_storage addr;
+	PurpleSockaddr addr;
 	socklen_t len = sizeof(addr);
 
 	g_return_val_if_fail(fd >= 0, -1);
 
-	if (getsockname(fd, (struct sockaddr *)&addr, &len))
+	if (getsockname(fd, &(addr.sa), &len))
 		return -1;
 
-	return ((struct sockaddr *)&addr)->sa_family;
+	return addr.sa.sa_family;
 }
 
 gboolean
 purple_socket_speaks_ipv4(int fd)
 {
 	int family;
-	
+
 	g_return_val_if_fail(fd >= 0, FALSE);
 
 	family = purple_socket_get_family(fd);
--- a/pidgin/gtkimhtml.c	Sat Apr 17 22:22:21 2010 +0000
+++ b/pidgin/gtkimhtml.c	Sat Apr 17 22:22:52 2010 +0000
@@ -1185,8 +1185,14 @@
 		printf("\n");
 		}
 #endif
-		text = g_malloc(selection_data->length);
+
+		text = g_malloc(selection_data->length + 1);
 		memcpy(text, selection_data->data, selection_data->length);
+		/* Make sure the paste data is null-terminated.  Given that
+		 * we're passed length (but assume later that it is
+		 * null-terminated), this seems sensible to me.
+		 */
+		text[selection_data->length] = '\0';
 	}
 
 #ifdef _WIN32