Sun, 07 Feb 2021 01:33:01 -0600
Implement mitigation for GHSL-2021-045
This add a static inline version of `g_memdup2` if the version of glib we're
compiling against doesn't have the function.
GHSL-2021-045 was originally reported to glib at
https://gitlab.gnome.org/GNOME/glib/-/issues/2319.
More information about the entire situation can be found on the gnome
desktop-devel-list at
https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html
Testing Done:
Compiled and ran tests locally.
Reviewed at https://reviews.imfreedom.org/r/483/
--- a/libpurple/ciphers/hmac.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/ciphers/hmac.c Sun Feb 07 01:33:01 2021 -0600 @@ -21,6 +21,8 @@ */ #include <cipher.h> +#include "glibcompat.h" + #include <util.h> struct HMAC_Context { @@ -157,7 +159,7 @@ full_key = g_malloc(100); /* TODO: Should be enough for now... */ purple_cipher_context_digest(hctx->hash, 100, full_key, &key_len); } else - full_key = g_memdup(key, key_len); + full_key = g_memdup2(key, key_len); if (key_len < blocksize) { full_key = g_realloc(full_key, blocksize);
--- a/libpurple/dnsquery.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/dnsquery.c Sun Feb 07 01:33:01 2021 -0600 @@ -29,6 +29,7 @@ #include "internal.h" #include "debug.h" #include "dnsquery.h" +#include "glibcompat.h" #include "network.h" #include "notify.h" #include "prefs.h" @@ -169,7 +170,7 @@ { GSList *hosts = NULL; hosts = g_slist_append(hosts, GINT_TO_POINTER(res->ai_addrlen)); - hosts = g_slist_append(hosts, g_memdup(res->ai_addr, res->ai_addrlen)); + hosts = g_slist_append(hosts, g_memdup2(res->ai_addr, res->ai_addrlen)); purple_dnsquery_resolved(query_data, hosts); freeaddrinfo(res); @@ -187,7 +188,7 @@ sin.sin_family = AF_INET; sin.sin_port = htons(query_data->port); hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); - hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); + hosts = g_slist_append(hosts, g_memdup2(&sin, sizeof(sin))); purple_dnsquery_resolved(query_data, hosts); return TRUE; @@ -779,7 +780,7 @@ query_data->hosts = g_slist_append(query_data->hosts, GSIZE_TO_POINTER(res->ai_addrlen)); query_data->hosts = g_slist_append(query_data->hosts, - g_memdup(res->ai_addr, res->ai_addrlen)); + g_memdup2(res->ai_addr, res->ai_addrlen)); res = res->ai_next; } freeaddrinfo(tmp); @@ -796,7 +797,7 @@ query_data->hosts = g_slist_append(query_data->hosts, GSIZE_TO_POINTER(sizeof(sin))); query_data->hosts = g_slist_append(query_data->hosts, - g_memdup(&sin, sizeof(sin))); + g_memdup2(&sin, sizeof(sin))); } else { query_data->error_message = g_strdup_printf(_("Error resolving %s: %d"), query_data->hostname, h_errno); } @@ -874,7 +875,7 @@ sin.sin_port = htons(query_data->port); hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); - hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); + hosts = g_slist_append(hosts, g_memdup2(&sin, sizeof(sin))); purple_dnsquery_resolved(query_data, hosts); }
--- a/libpurple/ft.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/ft.c Sun Feb 07 01:33:01 2021 -0600 @@ -26,6 +26,7 @@ #include "internal.h" #include "dbus-maybe.h" #include "ft.h" +#include "glibcompat.h" #include "network.h" #include "notify.h" #include "prefs.h" @@ -302,7 +303,7 @@ if (print_thumbnail && thumbnail_data) { gchar *message_with_img; - gpointer data = g_memdup(thumbnail_data, size); + gpointer data = g_memdup2(thumbnail_data, size); int id = purple_imgstore_add_with_id(data, size, NULL); message_with_img = @@ -1791,7 +1792,7 @@ gchar *old_mimetype = priv->thumbnail_mimetype; if (thumbnail && size > 0) { - priv->thumbnail_data = g_memdup(thumbnail, size); + priv->thumbnail_data = g_memdup2(thumbnail, size); priv->thumbnail_size = size; priv->thumbnail_mimetype = g_strdup(mimetype); } else {
--- a/libpurple/gaim-compat.h Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/gaim-compat.h Sun Feb 07 01:33:01 2021 -0600 @@ -28,6 +28,8 @@ #include <glib.h> +#include "glibcompat.h" + /* from account.h */ #define GaimAccountUiOps PurpleAccountUiOps #define GaimAccount PurpleAccount @@ -338,13 +340,13 @@ #define GaimBuddyIcon PurpleBuddyIcon #define gaim_buddy_icon_new(account, username, icon_data, icon_len)\ - purple_buddy_icon_new(account, username, g_memdup(icon_data, icon_len), icon_len) + purple_buddy_icon_new(account, username, g_memdup2(icon_data, icon_len), icon_len) #define gaim_buddy_icon_ref purple_buddy_icon_ref #define gaim_buddy_icon_unref purple_buddy_icon_unref #define gaim_buddy_icon_update purple_buddy_icon_update #define gaim_buddy_icon_set_data(icon, data, len) \ - purple_buddy_icon_set_data(icon, g_memdup(data, len), len, NULL); + purple_buddy_icon_set_data(icon, g_memdup2(data, len), len, NULL); #define gaim_buddy_icon_get_account purple_buddy_icon_get_account #define gaim_buddy_icon_get_username purple_buddy_icon_get_username @@ -352,7 +354,7 @@ #define gaim_buddy_icon_get_type purple_buddy_icon_get_extension #define gaim_buddy_icons_set_for_user(icon, data, len) \ - purple_buddy_icons_set_for_user(icon, g_memdup(data, len), len, NULL) + purple_buddy_icons_set_for_user(icon, g_memdup2(data, len), len, NULL) #define gaim_buddy_icons_set_caching purple_buddy_icons_set_caching #define gaim_buddy_icons_is_caching purple_buddy_icons_is_caching #define gaim_buddy_icons_set_cache_dir purple_buddy_icons_set_cache_dir @@ -960,7 +962,7 @@ #define GaimStoredImage PurpleStoredImage #define gaim_imgstore_add(data, size, filename) \ - purple_imgstore_add_with_id(g_memdup(data, size), size, filename) + purple_imgstore_add_with_id(g_memdup2(data, size), size, filename) #define gaim_imgstore_get purple_imgstore_find_by_id #define gaim_imgstore_get_data purple_imgstore_get_data #define gaim_imgstore_get_size purple_imgstore_get_size
--- a/libpurple/glibcompat.h Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/glibcompat.h Sun Feb 07 01:33:01 2021 -0600 @@ -52,5 +52,23 @@ #endif /* __clang__ */ +/* Backport the static inline version of g_memdup2 if we don't have g_memdup2. + * see https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html + * for more information. + */ +#if !GLIB_CHECK_VERSION(2, 67, 3) +static inline gpointer +g_memdup2(gconstpointer mem, gsize byte_size) { + gpointer new_mem = NULL; + + if(mem && byte_size != 0) { + new_mem = g_malloc (byte_size); + memcpy (new_mem, mem, byte_size); + } + + return new_mem; +} +#endif /* !GLIB_CHECK_VERSION(2, 67, 3) */ + #endif /* PURPLE_GLIBCOMPAT_H */
--- a/libpurple/mediamanager.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/mediamanager.c Sun Feb 07 01:33:01 2021 -0600 @@ -28,6 +28,7 @@ #include "account.h" #include "debug.h" +#include "glibcompat.h" #include "media.h" #include "mediamanager.h" @@ -1967,7 +1968,7 @@ media, session_id, participant); if (info && info->appsrc && info->connected) { - GstBuffer *gstbuffer = gst_buffer_new_wrapped (g_memdup (buffer, size), + GstBuffer *gstbuffer = gst_buffer_new_wrapped (g_memdup2 (buffer, size), size); GstAppSrc *appsrc = gst_object_ref (info->appsrc);
--- a/libpurple/protocols/bonjour/buddy.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/bonjour/buddy.c Sun Feb 07 01:33:01 2021 -0600 @@ -22,6 +22,7 @@ #include "account.h" #include "blist.h" #include "bonjour.h" +#include "glibcompat.h" #include "mdns_interface.h" #include "debug.h" @@ -243,7 +244,7 @@ hash, buddy->phsh ? buddy->phsh : "(null)"); purple_buddy_icons_set_for_user(buddy->account, buddy->name, - g_memdup(data, len), len, hash); + g_memdup2(data, len), len, hash); g_free(hash); }
--- a/libpurple/protocols/gg/gg.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/gg/gg.c Sun Feb 07 01:33:01 2021 -0600 @@ -35,6 +35,7 @@ #include "blist.h" #include "accountopt.h" #include "debug.h" +#include "glibcompat.h" #include "util.h" #include "request.h" #include "xmlnode.h" @@ -521,7 +522,7 @@ if (buddy == NULL) goto out; - buddy_icon_data = g_memdup(data, len); + buddy_icon_data = g_memdup2(data, len); purple_buddy_icons_set_for_user(account, purple_buddy_get_name(buddy), buddy_icon_data, len, d->avatar_url); @@ -982,7 +983,7 @@ gchar *handlerid = g_strdup_printf("IMGID_HANDLER-%i", ev->event.image_reply.crc32); imgid = purple_imgstore_add_with_id( - g_memdup(ev->event.image_reply.image, ev->event.image_reply.size), + g_memdup2(ev->event.image_reply.image, ev->event.image_reply.size), ev->event.image_reply.size, ev->event.image_reply.filename);
--- a/libpurple/protocols/irc/dcc_send.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/irc/dcc_send.c Sun Feb 07 01:33:01 2021 -0600 @@ -25,6 +25,7 @@ #include "irc.h" #include "debug.h" #include "ft.h" +#include "glibcompat.h" #include "notify.h" #include "network.h" @@ -207,7 +208,7 @@ xd->rxlen -= 4; if (xd->rxlen) { - unsigned char *tmp = g_memdup(xd->rxqueue + 4, xd->rxlen); + unsigned char *tmp = g_memdup2(xd->rxqueue + 4, xd->rxlen); g_free(xd->rxqueue); xd->rxqueue = tmp; } else {
--- a/libpurple/protocols/jabber/buddy.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/jabber/buddy.c Sun Feb 07 01:33:01 2021 -0600 @@ -22,6 +22,7 @@ */ #include "internal.h" #include "debug.h" +#include "glibcompat.h" #include "imgstore.h" #include "prpl.h" #include "notify.h" @@ -1181,7 +1182,7 @@ char *img_text; char *hash; - jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png"))); + jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup2(data, size), size, "logo.png"))); img_text = g_strdup_printf("<img id='%d'>", GPOINTER_TO_INT(jbi->vcard_imgids->data)); purple_notify_user_info_add_pair(user_info, (photo ? _("Photo") : _("Logo")), img_text);
--- a/libpurple/protocols/jabber/data.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/jabber/data.c Sun Feb 07 01:33:01 2021 -0600 @@ -29,6 +29,7 @@ #include "data.h" #include "debug.h" +#include "glibcompat.h" #include "xmlnode.h" #include "util.h" #include "iq.h" @@ -60,7 +61,7 @@ data->size = size; data->ephemeral = ephemeral; - data->data = g_memdup(rawdata, size); + data->data = g_memdup2(rawdata, size); return data; }
--- a/libpurple/protocols/jabber/useravatar.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/jabber/useravatar.c Sun Feb 07 01:33:01 2021 -0600 @@ -23,6 +23,8 @@ #include "internal.h" +#include "glibcompat.h" + #include "useravatar.h" #include "pep.h" #include "debug.h" @@ -273,7 +275,7 @@ goto out; } - icon_data = g_memdup(url_text, len); + icon_data = g_memdup2(url_text, len); purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, icon_data, len, info->id); out:
--- a/libpurple/protocols/oscar/odc.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/oscar/odc.c Sun Feb 07 01:33:01 2021 -0600 @@ -26,6 +26,7 @@ /* From Purple */ #include "conversation.h" #include "imgstore.h" +#include "glibcompat.h" #include "util.h" #define DIRECTIM_MAX_FILESIZE 52428800 @@ -354,7 +355,7 @@ if ((embedded_data != NULL) && (embedded_data->size == size)) { - imgid = purple_imgstore_add_with_id(g_memdup(embedded_data->data, size), size, src); + imgid = purple_imgstore_add_with_id(g_memdup2(embedded_data->data, size), size, src); /* Record the image number */ images = g_slist_append(images, GINT_TO_POINTER(imgid));
--- a/libpurple/protocols/oscar/oft.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/oscar/oft.c Sun Feb 07 01:33:01 2021 -0600 @@ -56,6 +56,7 @@ #include "oscar.h" #include "peer.h" +#include "glibcompat.h" #include "util.h" #define CHECKSUM_BUFFER_SIZE 256 * 1024 @@ -230,7 +231,7 @@ g_free(conn->xferdata.name); memcpy(&(conn->xferdata), frame, sizeof(OftFrame)); - conn->xferdata.name = g_memdup(frame->name, frame->name_length); + conn->xferdata.name = g_memdup2(frame->name, frame->name_length); } /**
--- a/libpurple/protocols/oscar/oscar.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/oscar/oscar.c Sun Feb 07 01:33:01 2021 -0600 @@ -38,6 +38,7 @@ #include "core.h" #include "debug.h" #include "encoding.h" +#include "glibcompat.h" #include "imgstore.h" #include "network.h" #include "notify.h" @@ -1065,7 +1066,7 @@ conn = flap_connection_new(od, SNAC_FAMILY_LOCATE); conn->cookielen = cookielen; - conn->cookie = g_memdup(cookie, cookielen); + conn->cookie = g_memdup2(cookie, cookielen); /* * Use TLS only if the server provided us with a tls_certname. The server might not specify a tls_certname even if we requested to use TLS, @@ -1185,7 +1186,7 @@ host = g_strndup(info->bosip, i); newconn = flap_connection_new(od, SNAC_FAMILY_LOCATE); newconn->cookielen = info->cookielen; - newconn->cookie = g_memdup(info->cookie, info->cookielen); + newconn->cookie = g_memdup2(info->cookie, info->cookielen); if (od->use_ssl) { @@ -1353,7 +1354,7 @@ newconn = flap_connection_new(od, redir->group); newconn->cookielen = redir->cookielen; - newconn->cookie = g_memdup(redir->cookie, redir->cookielen); + newconn->cookie = g_memdup2(redir->cookie, redir->cookielen); if (newconn->type == SNAC_FAMILY_CHAT) { struct chat_connection *cc; @@ -1829,7 +1830,7 @@ else if (args->type & OSCAR_CAPABILITY_BUDDYICON) { purple_buddy_icons_set_for_user(account, userinfo->bn, - g_memdup(args->info.icon.icon, args->info.icon.length), + g_memdup2(args->info.icon.icon, args->info.icon.length), args->info.icon.length, NULL); } @@ -2711,7 +2712,7 @@ if ((iconlen > 0) && (iconlen != 90)) { char *b16 = purple_base16_encode(iconcsum, iconcsumlen); purple_buddy_icons_set_for_user(purple_connection_get_account(gc), - bn, g_memdup(icon, iconlen), iconlen, b16); + bn, g_memdup2(icon, iconlen), iconlen, b16); g_free(b16); }
--- a/libpurple/protocols/oscar/snac.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/oscar/snac.c Sun Feb 07 01:33:01 2021 -0600 @@ -34,6 +34,8 @@ #include "oscar.h" +#include "glibcompat.h" + /* * Called from oscar_session_new() to initialize the hash. */ @@ -57,7 +59,7 @@ snac.flags = flags; if (datalen) - snac.data = g_memdup(data, datalen); + snac.data = g_memdup2(data, datalen); else snac.data = NULL; @@ -76,7 +78,7 @@ if (!newsnac) return 0; - snac = g_memdup(newsnac, sizeof(aim_snac_t)); + snac = g_memdup2(newsnac, sizeof(aim_snac_t)); snac->issuetime = time(NULL); index = snac->id % FAIM_SNAC_HASH_SIZE;
--- a/libpurple/protocols/oscar/tlv.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/oscar/tlv.c Sun Feb 07 01:33:01 2021 -0600 @@ -20,6 +20,8 @@ #include "oscar.h" +#include "glibcompat.h" + static aim_tlv_t * createtlv(guint16 type, guint16 length, guint8 *value) { @@ -300,7 +302,7 @@ tlv = createtlv(type, length, NULL); if (tlv->length > 0) - tlv->value = g_memdup(value, length); + tlv->value = g_memdup2(value, length); *list = g_slist_append(*list, tlv); @@ -535,7 +537,7 @@ g_free(tlv->value); tlv->length = length; if (tlv->length > 0) { - tlv->value = g_memdup(value, length); + tlv->value = g_memdup2(value, length); } else tlv->value = NULL;
--- a/libpurple/protocols/silc/buddy.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/silc/buddy.c Sun Feb 07 01:33:01 2021 -0600 @@ -23,6 +23,8 @@ #include "silcpurple.h" #include "wb.h" +#include "glibcompat.h" + /***************************** Key Agreement *********************************/ static void @@ -985,7 +987,7 @@ data = silc_mime_get_data(usericon, &data_len); if (data) { /* TODO: Check if SILC gives us something to use as the checksum instead */ - purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup(data, data_len), data_len, NULL); + purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup2(data, data_len), data_len, NULL); } } silc_mime_free(usericon);
--- a/libpurple/protocols/silc/ops.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/silc/ops.c Sun Feb 07 01:33:01 2021 -0600 @@ -24,6 +24,8 @@ #include "imgstore.h" #include "wb.h" +#include "glibcompat.h" + static void silc_channel_message(SilcClient client, SilcClientConnection conn, SilcClientEntry sender, SilcChannelEntry channel, @@ -206,7 +208,7 @@ if (channel && !convo) goto out; - imgid = purple_imgstore_add_with_id(g_memdup(data, data_len), data_len, ""); + imgid = purple_imgstore_add_with_id(g_memdup2(data, data_len), data_len, ""); if (imgid) { cflags |= PURPLE_MESSAGE_IMAGES | PURPLE_MESSAGE_RECV; g_snprintf(tmp, sizeof(tmp), "<IMG ID=\"%d\">", imgid);
--- a/libpurple/protocols/silc10/buddy.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/silc10/buddy.c Sun Feb 07 01:33:01 2021 -0600 @@ -22,6 +22,8 @@ #include "silcpurple.h" #include "wb.h" +#include "glibcompat.h" + /***************************** Key Agreement *********************************/ static void @@ -992,7 +994,7 @@ data = silc_mime_get_data(m, &data_len); if (data) { /* TODO: Check if SILC gives us something to use as the checksum instead */ - purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup(data, data_len), data_len, NULL); + purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup2(data, data_len), data_len, NULL); } } silc_mime_free(m);
--- a/libpurple/protocols/silc10/ops.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/silc10/ops.c Sun Feb 07 01:33:01 2021 -0600 @@ -23,6 +23,8 @@ #include "imgstore.h" #include "wb.h" +#include "glibcompat.h" + static void silc_channel_message(SilcClient client, SilcClientConnection conn, SilcClientEntry sender, SilcChannelEntry channel, @@ -161,7 +163,7 @@ if (channel && !convo) goto out; - imgid = purple_imgstore_add_with_id(g_memdup(data, data_len), data_len, ""); + imgid = purple_imgstore_add_with_id(g_memdup2(data, data_len), data_len, ""); if (imgid) { cflags |= PURPLE_MESSAGE_IMAGES | PURPLE_MESSAGE_RECV; g_snprintf(tmp, sizeof(tmp), "<IMG ID=\"%d\">", imgid);
--- a/libpurple/protocols/simple/simple.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/protocols/simple/simple.c Sun Feb 07 01:33:01 2021 -0600 @@ -31,6 +31,7 @@ #include "conversation.h" #include "dnsquery.h" #include "debug.h" +#include "glibcompat.h" #include "notify.h" #include "privacy.h" #include "prpl.h" @@ -357,7 +358,7 @@ while(parts[i]) { purple_debug_info("simple", "parts[i] %s\n", parts[i]); if((tmp = parse_attribute("gssapi-data=\"", parts[i]))) { - auth->nonce = g_memdup(purple_ntlm_parse_type2(tmp, &auth->flags), 8); + auth->nonce = g_memdup2(purple_ntlm_parse_type2(tmp, &auth->flags), 8); g_free(tmp); } if((tmp = parse_attribute("targetname=\"",
--- a/libpurple/proxy.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/proxy.c Sun Feb 07 01:33:01 2021 -0600 @@ -35,6 +35,7 @@ #include "cipher.h" #include "debug.h" #include "dnsquery.h" +#include "glibcompat.h" #include "notify.h" #include "ntlm.h" #include "prefs.h" @@ -1350,7 +1351,7 @@ hosts = g_slist_delete_link(hosts, hosts); } - connect_data->write_buffer = g_memdup(packet, sizeof(packet)); + connect_data->write_buffer = g_memdup2(packet, sizeof(packet)); connect_data->write_buf_len = sizeof(packet); connect_data->written_len = 0; connect_data->read_cb = s4_canread;
--- a/libpurple/request.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/request.c Sun Feb 07 01:33:01 2021 -0600 @@ -27,6 +27,7 @@ #include "internal.h" +#include "glibcompat.h" #include "notify.h" #include "request.h" #include "debug.h" @@ -1023,7 +1024,7 @@ field = purple_request_field_new(id, text, PURPLE_REQUEST_FIELD_IMAGE); - field->u.image.buffer = g_memdup(buf, size); + field->u.image.buffer = g_memdup2(buf, size); field->u.image.size = size; field->u.image.scale_x = 1; field->u.image.scale_y = 1;
--- a/libpurple/util.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/util.c Sun Feb 07 01:33:01 2021 -0600 @@ -27,6 +27,7 @@ #include "conversation.h" #include "core.h" #include "debug.h" +#include "glibcompat.h" #include "notify.h" #include "ntlm.h" #include "prpl.h" @@ -4229,7 +4230,7 @@ gfud->user_agent = g_strdup(user_agent); gfud->http11 = http11; gfud->full = full; - gfud->request = request_len ? g_memdup(request, request_len) : NULL; + gfud->request = request_len ? g_memdup2(request, request_len) : NULL; gfud->request_len = request_len; gfud->include_headers = include_headers; gfud->fd = -1;
--- a/libpurple/xmlnode.c Thu Jan 21 23:55:56 2021 -0600 +++ b/libpurple/xmlnode.c Sun Feb 07 01:33:01 2021 -0600 @@ -30,6 +30,7 @@ #define _PURPLE_XMLNODE_C_ #include "internal.h" +#include "glibcompat.h" #include "debug.h" #include <libxml/parser.h> @@ -113,7 +114,7 @@ child = new_node(NULL, XMLNODE_TYPE_DATA); - child->data = g_memdup(data, real_size); + child->data = g_memdup2(data, real_size); child->data_sz = real_size; xmlnode_insert_child(node, child); @@ -824,7 +825,7 @@ ret->xmlns = g_strdup(src->xmlns); if (src->data) { if (src->data_sz) { - ret->data = g_memdup(src->data, src->data_sz); + ret->data = g_memdup2(src->data, src->data_sz); ret->data_sz = src->data_sz; } else { ret->data = g_strdup(src->data);
--- a/pidgin/gtkaccount.c Thu Jan 21 23:55:56 2021 -0600 +++ b/pidgin/gtkaccount.c Sun Feb 07 01:33:01 2021 -0600 @@ -31,6 +31,7 @@ #include "accountopt.h" #include "core.h" #include "debug.h" +#include "glibcompat.h" #include "notify.h" #include "plugin.h" #include "prefs.h" @@ -748,7 +749,7 @@ if (img) { len = purple_imgstore_get_size(img); - data = g_memdup(purple_imgstore_get_data(img), len); + data = g_memdup2(purple_imgstore_get_data(img), len); } set_dialog_icon(dialog, data, len, g_strdup(purple_account_get_buddy_icon_path(dialog->account))); @@ -1343,7 +1344,7 @@ { size_t len = purple_imgstore_get_size(dialog->icon_img); purple_buddy_icons_set_account_icon(account, - g_memdup(purple_imgstore_get_data(dialog->icon_img), len), + g_memdup2(purple_imgstore_get_data(dialog->icon_img), len), len); purple_account_set_buddy_icon_path(account, purple_imgstore_get_filename(dialog->icon_img)); }
--- a/pidgin/gtkblist-theme.c Thu Jan 21 23:55:56 2021 -0600 +++ b/pidgin/gtkblist-theme.c Sun Feb 07 01:33:01 2021 -0600 @@ -23,6 +23,8 @@ #include "internal.h" #include "gtkblist-theme.h" +#include "glibcompat.h" + #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \ ((PidginBlistThemePrivate *) ((PIDGIN_BLIST_THEME(Gobject))->priv)) @@ -729,7 +731,7 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); g_free(priv->layout); - priv->layout = g_memdup(layout, sizeof(PidginBlistLayout)); + priv->layout = g_memdup2(layout, sizeof(PidginBlistLayout)); } void
--- a/pidgin/gtkconv.c Thu Jan 21 23:55:56 2021 -0600 +++ b/pidgin/gtkconv.c Sun Feb 07 01:33:01 2021 -0600 @@ -42,6 +42,7 @@ #include "cmds.h" #include "core.h" #include "debug.h" +#include "glibcompat.h" #include "idle.h" #include "imgstore.h" #include "log.h" @@ -5964,7 +5965,7 @@ gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); } else { - char *new_message = g_memdup(displaying, length); + char *new_message = g_memdup2(displaying, length); char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); /* The initial offset is to deal with * escaped entities making the string longer */ @@ -6085,7 +6086,7 @@ length += pre_len + post_len; g_free(pre); } else - with_font_tag = g_memdup(new_message, length); + with_font_tag = g_memdup2(new_message, length); gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), with_font_tag, gtk_font_options | gtk_font_options_all); @@ -10312,7 +10313,7 @@ if (i < numcolors) { GdkColor *c = colors; purple_debug_warning("gtkconv", "Unable to generate enough random colors before timeout. %u colors found.\n", i); - colors = g_memdup(c, i * sizeof(GdkColor)); + colors = g_memdup2(c, i * sizeof(GdkColor)); g_free(c); *color_count = i; }
--- a/pidgin/gtksmiley.c Thu Jan 21 23:55:56 2021 -0600 +++ b/pidgin/gtksmiley.c Sun Feb 07 01:33:01 2021 -0600 @@ -29,6 +29,7 @@ #include "pidgin.h" #include "debug.h" +#include "glibcompat.h" #include "notify.h" #include "smiley.h" @@ -716,7 +717,7 @@ ps = pidgin_smiley_edit(dialog->window, NULL); pidgin_smiley_editor_set_image(ps, image); - pidgin_smiley_editor_set_data(ps, g_memdup(smileydata, len), len); + pidgin_smiley_editor_set_data(ps, g_memdup2(smileydata, len), len); } static void
--- a/pidgin/plugins/gevolution/gevolution.c Thu Jan 21 23:55:56 2021 -0600 +++ b/pidgin/plugins/gevolution/gevolution.c Sun Feb 07 01:33:01 2021 -0600 @@ -21,6 +21,8 @@ #include "internal.h" #include "pidgin.h" +#include "libpurple/glibcompat.h" + #include "connection.h" #include "debug.h" #include "prefs.h" @@ -340,7 +342,7 @@ backup_blist_ui_ops = purple_blist_get_ui_ops(); - blist_ui_ops = g_memdup(backup_blist_ui_ops, sizeof(PurpleBlistUiOps)); + blist_ui_ops = g_memdup2(backup_blist_ui_ops, sizeof(PurpleBlistUiOps)); blist_ui_ops->request_add_buddy = request_add_buddy; purple_blist_set_ui_ops(blist_ui_ops);