--- a/libpurple/plugins/tcl/tcl_glib.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/plugins/tcl/tcl_glib.c Thu Apr 03 00:47:13 2014 +0200
@@ -224,7 +224,8 @@
- fev = (struct tcl_file_event *)ckalloc(sizeof(struct tcl_file_event));
+ /* ckalloc returns memory "suitably aligned for any use" */ + fev = (gpointer)ckalloc(sizeof(struct tcl_file_event)); memset(fev, 0, sizeof(struct tcl_file_event));
fev->header.proc = tcl_file_event_callback;
--- a/libpurple/protocols/bonjour/bonjour_ft.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/bonjour/bonjour_ft.c Thu Apr 03 00:47:13 2014 +0200
@@ -541,6 +541,7 @@
#if defined(AF_INET6) && defined(HAVE_GETADDRINFO)
struct addrinfo hint, *res = NULL;
+ common_sockaddr_t addr; memset(&hint, 0, sizeof(hint));
@@ -550,9 +551,11 @@
ret = getaddrinfo(host, NULL, &hint, &res);
+ memcpy(&addr, res->ai_addr, sizeof(addr)); - if(res->ai_family != AF_INET6 ||
- !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr)) {
+ if (res->ai_family != AF_INET6 || + !IN6_IS_ADDR_LINKLOCAL(&addr.in6.sin6_addr)) --- a/libpurple/protocols/bonjour/jabber.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/bonjour/jabber.c Thu Apr 03 00:47:13 2014 +0200
@@ -705,14 +705,14 @@
-start_serversocket_listening(int port, int socket, struct sockaddr *addr, size_t addr_size, gboolean ip6, gboolean allow_port_fallback)
+start_serversocket_listening(int port, int socket, common_sockaddr_t *addr, size_t addr_size, gboolean ip6, gboolean allow_port_fallback) purple_debug_info("bonjour", "Attempting to bind IPv%d socket to port %d.\n", ip6 ? 6 : 4, port);
/* Try to use the specified port - if it isn't available, use a random port */
- if (bind(socket, addr, addr_size) != 0) {
+ if (bind(socket, &addr->sa, addr_size) != 0) { purple_debug_info("bonjour", "Unable to bind to specified "
"port %i: %s\n", port, g_strerror(errno));
@@ -723,12 +723,12 @@
- ((struct sockaddr_in6 *) addr)->sin6_port = 0;
+ addr->in6.sin6_port = 0; - ((struct sockaddr_in *) addr)->sin_port = 0;
- if (bind(socket, addr, addr_size) != 0) {
+ if (bind(socket, &addr->sa, addr_size) != 0) { purple_debug_error("bonjour", "Unable to bind IPv%d socket to port: %s\n", ip6 ? 6 : 4, g_strerror(errno));
@@ -774,16 +774,17 @@
if (jdata->socket6 != -1) {
- struct sockaddr_in6 addr6;
+ common_sockaddr_t addr6; setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
- memset(&addr6, 0, sizeof(addr6));
- addr6.sin6_family = AF_INET6;
- addr6.sin6_port = htons(jdata->port);
- addr6.sin6_addr = in6addr_any;
- ipv6_port = start_serversocket_listening(jdata->port, jdata->socket6, (struct sockaddr *) &addr6, sizeof(addr6), TRUE, TRUE);
+ memset(&addr6, 0, sizeof(addr6)); + addr6.in6.sin6_family = AF_INET6; + addr6.in6.sin6_port = htons(jdata->port); + addr6.in6.sin6_addr = in6addr_any; + ipv6_port = start_serversocket_listening(jdata->port, + jdata->socket6, &addr6, sizeof(addr6), TRUE, TRUE); /* Open a watcher in the socket we have just opened */
jdata->watcher_id6 = purple_input_add(jdata->socket6, PURPLE_INPUT_READ, _server_socket_handler, jdata);
@@ -796,11 +797,12 @@
if (jdata->socket != -1) {
- struct sockaddr_in addr4;
+ common_sockaddr_t addr4; memset(&addr4, 0, sizeof(addr4));
- addr4.sin_family = AF_INET;
- addr4.sin_port = htons(jdata->port);
- ipv4_port = start_serversocket_listening(jdata->port, jdata->socket, (struct sockaddr *) &addr4, sizeof(addr4), FALSE, ipv6_port != -1);
+ addr4.in.sin_family = AF_INET; + addr4.in.sin_port = htons(jdata->port); + ipv4_port = start_serversocket_listening(jdata->port, jdata->socket, + &addr4, sizeof(addr4), FALSE, ipv6_port != -1); /* Open a watcher in the socket we have just opened */
jdata->watcher_id = purple_input_add(jdata->socket, PURPLE_INPUT_READ, _server_socket_handler, jdata);
@@ -1367,7 +1369,7 @@
#ifdef HAVE_GETIFADDRS /* This is required for IPv6 */
struct ifaddrs *ifap, *ifa;
+ common_sockaddr_t addr; char addrstr[INET6_ADDRSTRLEN];
@@ -1381,23 +1383,25 @@
if (!(ifa->ifa_flags & IFF_RUNNING) || (ifa->ifa_flags & IFF_LOOPBACK) || ifa->ifa_addr == NULL)
+ memcpy(&addr, ifa->ifa_addr, sizeof(addr)); - switch (addr->sa_family) {
+ switch (addr.sa.sa_family) { - address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in *)addr)->sin_addr,
+ address_text = inet_ntop(addr.sa.sa_family, addrstr, sizeof(addrstr));
- address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in6 *)addr)->sin6_addr,
+ address_text = inet_ntop(addr.sa.sa_family, addrstr, sizeof(addrstr));
if (address_text != NULL) {
- if (addr->sa_family == AF_INET)
+ if (addr.sa.sa_family == AF_INET) ips = g_slist_append(ips, g_strdup(address_text));
ips = g_slist_prepend(ips, g_strdup(address_text));
--- a/libpurple/protocols/gg/resolver-purple.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/gg/resolver-purple.c Thu Apr 03 00:47:13 2014 +0200
@@ -89,28 +89,28 @@
while (hosts && (hosts = g_slist_delete_link(hosts, hosts))) {
- const struct sockaddr *addr = hosts->data;
+ common_sockaddr_t addr; char dst[INET6_ADDRSTRLEN];
- if (addr->sa_family == AF_INET6) {
- inet_ntop(addr->sa_family,
- &((struct sockaddr_in6 *) addr)->sin6_addr,
+ memcpy(&addr, hosts->data, sizeof(addr)); + if (addr.sa.sa_family == AF_INET6) { + inet_ntop(addr.sa.sa_family, &addr.in6.sin6_addr, purple_debug_misc("gg", "ggp_resolver_purple_cb "
"ipv6 (ignore): %s\n", dst);
- } else if (addr->sa_family == AF_INET) {
- const struct in_addr addr_ipv4 =
- ((struct sockaddr_in *) addr)->sin_addr;
- inet_ntop(addr->sa_family, &addr_ipv4,
+ } else if (addr.sa.sa_family == AF_INET) { + inet_ntop(addr.sa.sa_family, &addr.in.sin_addr, purple_debug_misc("gg", "ggp_resolver_purple_cb "
g_assert(ipv4_count < all_count);
- addresses[ipv4_count++] = addr_ipv4;
+ addresses[ipv4_count++] = addr.in.sin_addr; purple_debug_warning("gg", "ggp_resolver_purple_cb "
- "unexpected sa_family: %d\n", addr->sa_family);
+ "unexpected sa_family: %d\n", --- a/libpurple/protocols/jabber/disco.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/jabber/disco.c Thu Apr 03 00:47:13 2014 +0200
@@ -436,18 +436,20 @@
if (hosts && g_slist_next(hosts)) {
- struct sockaddr *addr = g_slist_next(hosts)->data;
+ common_sockaddr_t addr; char dst[INET6_ADDRSTRLEN];
- if (addr->sa_family == AF_INET6) {
- inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr,
+ memcpy(&addr, g_slist_next(hosts)->data, sizeof(addr)); + if (addr.sa.sa_family == AF_INET6) { + inet_ntop(addr.sa.sa_family, &addr.in6.sin6_addr, - port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
+ port = ntohs(addr.in6.sin6_port); - inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr,
+ inet_ntop(addr.sa.sa_family, &addr.in.sin_addr, - port = ntohs(((struct sockaddr_in *) addr)->sin_port);
+ port = ntohs(addr.in.sin_port); --- a/libpurple/protocols/jabber/google/jingleinfo.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/jabber/google/jingleinfo.c Thu Apr 03 00:47:13 2014 +0200
@@ -37,18 +37,20 @@
if (hosts && g_slist_next(hosts)) {
- struct sockaddr *addr = g_slist_next(hosts)->data;
+ common_sockaddr_t addr; char dst[INET6_ADDRSTRLEN];
- if (addr->sa_family == AF_INET6) {
- inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr,
+ memcpy(&addr, g_slist_next(hosts)->data, sizeof(addr)); + if (addr.sa.sa_family == AF_INET6) { + inet_ntop(addr.sa.sa_family, &addr.in6.sin6_addr, - port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
+ port = ntohs(addr.in6.sin6_port); - inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr,
+ inet_ntop(addr.sa.sa_family, &addr.in.sin_addr, - port = ntohs(((struct sockaddr_in *) addr)->sin_port);
+ port = ntohs(addr.in.sin_port); --- a/libpurple/protocols/msn/directconn.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/msn/directconn.c Thu Apr 03 00:47:13 2014 +0200
@@ -84,12 +84,13 @@
msn_dc_generate_nonce(MsnDirectConn *dc)
- nonce = (guint32 *)&dc->nonce;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) { + guint32 randval = g_random_int(); + memcpy(dc->nonce + sizeof(guint32) * i, + &randval, sizeof(guint32)); msn_dc_calculate_nonce_hash(dc->nonce_type, dc->nonce, sizeof(dc->nonce), dc->nonce_hash);
@@ -661,7 +662,8 @@
/* Wait for packet length */
while (dc->in_pos >= 4) {
- packet_length = GUINT32_FROM_LE(*((guint32*)dc->in_buffer));
+ memcpy(&packet_length, dc->in_buffer, sizeof(packet_length)); + packet_length = GUINT32_FROM_LE(packet_length); if (packet_length > DC_MAX_PACKET_SIZE) {
--- a/libpurple/protocols/msn/msnutils.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/msn/msnutils.c Thu Apr 03 00:47:13 2014 +0200
@@ -547,10 +547,9 @@
const guchar productID[] = MSNP15_WLM_PRODUCT_ID;
const char hexChars[] = "0123456789abcdef";
- unsigned char md5Hash[16];
- unsigned int *md5Parts;
- unsigned int *chlStringParts;
+ guint32 chlStringParts[BUFSIZE / sizeof(guint32)]; unsigned int newHashParts[5];
long long nHigh = 0, nLow = 0;
@@ -563,11 +562,10 @@
purple_hash_append(hash, (guchar *)input, strlen(input));
purple_hash_append(hash, productKey, sizeof(productKey) - 1);
- purple_hash_digest(hash, md5Hash, sizeof(md5Hash));
+ purple_hash_digest(hash, (guchar *)md5Parts, sizeof(md5Parts)); /* Split it into four integers */
- md5Parts = (unsigned int *)md5Hash;
for (i = 0; i < 4; i++) {
md5Parts[i] = GUINT_TO_LE(md5Parts[i]);
@@ -589,7 +587,7 @@
/* split into integers */
- chlStringParts = (unsigned int *)buf;
+ memcpy(&chlStringParts, &buf, sizeof(chlStringParts)); for (i = 0; i < (len / 4); i += 2) {
@@ -640,78 +638,96 @@
msn_read16le(const char *buf)
- return GUINT16_FROM_LE(*(guint16 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT16_FROM_LE(val); msn_read16be(const char *buf)
- return GUINT16_FROM_BE(*(guint16 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT16_FROM_BE(val); msn_read32le(const char *buf)
- return GUINT32_FROM_LE(*(guint32 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT32_FROM_LE(val); msn_read32be(const char *buf)
- return GUINT32_FROM_BE(*(guint32 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT32_FROM_BE(val); msn_read64le(const char *buf)
- return GUINT64_FROM_LE(*(guint64 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT64_FROM_LE(val); msn_read64be(const char *buf)
- return GUINT64_FROM_BE(*(guint64 *)buf);
+ memcpy(&val, buf, sizeof(val)); + return GUINT64_FROM_BE(val); msn_write8(char *buf, guint8 data)
+ memcpy(buf, &data, sizeof(data)); msn_write16le(char *buf, guint16 data)
- *(guint16 *)buf = GUINT16_TO_LE(data);
+ data = GUINT16_TO_LE(data); + memcpy(buf, &data, sizeof(data)); msn_write16be(char *buf, guint16 data)
- *(guint16 *)buf = GUINT16_TO_BE(data);
+ data = GUINT16_TO_BE(data); + memcpy(buf, &data, sizeof(data)); msn_write32le(char *buf, guint32 data)
- *(guint32 *)buf = GUINT32_TO_LE(data);
+ data = GUINT32_TO_LE(data); + memcpy(buf, &data, sizeof(data)); msn_write32be(char *buf, guint32 data)
- *(guint32 *)buf = GUINT32_TO_BE(data);
+ data = GUINT32_TO_BE(data); + memcpy(buf, &data, sizeof(data)); msn_write64le(char *buf, guint64 data)
- *(guint64 *)buf = GUINT64_TO_LE(data);
+ data = GUINT64_TO_LE(data); + memcpy(buf, &data, sizeof(data)); msn_write64be(char *buf, guint64 data)
- *(guint64 *)buf = GUINT64_TO_BE(data);
+ data = GUINT64_TO_BE(data); + memcpy(buf, &data, sizeof(data)); --- a/libpurple/protocols/msn/p2p.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/msn/p2p.c Thu Apr 03 00:47:13 2014 +0200
@@ -209,13 +209,13 @@
char *header_wire = NULL;
char *data_header_wire = NULL;
- if (header->header_tlv != NULL)
- header_wire = msn_tlvlist_write(header->header_tlv, (size_t *)&header->header_len);
+ if (header->header_tlv != NULL) { + header_wire = msn_tlvlist_write(header->header_tlv, &header->header_len); if (header->data_tlv != NULL)
- data_header_wire = msn_tlvlist_write(header->data_tlv, (size_t *)&header->data_header_len);
+ data_header_wire = msn_tlvlist_write(header->data_tlv, &header->data_header_len); header->data_header_len = 0;
--- a/libpurple/protocols/msn/slpcall.c Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/msn/slpcall.c Thu Apr 03 00:47:13 2014 +0200
@@ -281,12 +281,18 @@
- *(guint32 *)(nonce + 0) = GUINT32_TO_LE(n1);
- *(guint16 *)(nonce + 4) = GUINT16_TO_LE(n2);
- *(guint16 *)(nonce + 6) = GUINT16_TO_LE(n3);
- *(guint16 *)(nonce + 8) = GUINT16_TO_BE(n4);
- *(guint16 *)(nonce + 10) = GUINT16_TO_BE(n5);
- *(guint32 *)(nonce + 12) = GUINT32_TO_BE(n6);
+ n1 = GUINT32_TO_LE(n1); + n2 = GUINT16_TO_LE(n2); + n3 = GUINT16_TO_LE(n3); + n4 = GUINT16_TO_BE(n4); + n5 = GUINT16_TO_BE(n5); + n6 = GUINT32_TO_BE(n6); + memcpy(nonce + 0, &n1, sizeof(n1)); + memcpy(nonce + 4, &n2, sizeof(n2)); + memcpy(nonce + 6, &n3, sizeof(n3)); + memcpy(nonce + 8, &n4, sizeof(n4)); + memcpy(nonce + 10, &n5, sizeof(n5)); + memcpy(nonce + 12, &n6, sizeof(n6)); /* Invalid nonce, so ignore request */
--- a/libpurple/protocols/msn/tlv.h Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/msn/tlv.h Thu Apr 03 00:47:13 2014 +0200
@@ -52,7 +52,7 @@
int msn_tlvlist_count(GSList *list);
size_t msn_tlvlist_size(GSList *list);
gboolean msn_tlvlist_equal(GSList *one, GSList *two);
-char *msn_tlvlist_write(GSList *list, size_t *out_len);
+char *msn_tlvlist_write(GSList *list, guint8 *out_len); void msn_tlvlist_free(GSList *list);
int msn_tlvlist_add_raw(GSList **list, const guint8 type, const guint8 length, const char *value);