Port your module from g_memdup() to g_memdup2() now

Philip Withnall <[email protected]> Thu, 04 Feb 2021 17:28:35 +0000
Newsgroups gmane.comp.gnome.desktop
Message-ID <[email protected]>
Hi all,

GLib 2.67.3 will be released shortly with a new g_memdup2() API to
replace the old g_memdup() API. Please port to using g_memdup2() as
soon as possible: g_memdup() will be deprecated in GLib 2.67.4.

The old API took the size of the memory to duplicate as a guint,
whereas most memory functions take memory sizes as a gsize. This made
it easy to accidentally pass a gsize to g_memdup(). For large values,
that would lead to a silent truncation of the size from 64 to 32 bits,
and result in a heap area being returned which is significantly smaller
than what the caller expects. This can likely be exploited in various
modules to cause a heap buffer overflow.

Details here:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926

GLib 2.66.6 will also be released shortly, which will fix the bug
internally in GLib. It will not export g_memdup2() as a new public API
though. You’ll need to depend on GLib ≥2.67.3 for that, or copy the
`static inline` version of g_memdup2() from here:

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1927/diffs

Sorry for the short notice about this. Due to some oversights, the
vulnerability was made public today at the same time as we first heard
about it.

Thanks to Kevin Backhouse from GHSL for finding it and providing a
detailed report.

Philip

_______________________________________________
desktop-devel-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/desktop-devel-list
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEYZF/mMHWW1QW1G6zkslX8njioaoFAmAcLsMACgkQkslX8nji
oaqcLw/+IlnPJ/Oaq3GKawyw3NT2/4BpEwv0H0e/3V8i/wqIQAl7qoSvIhqzSQ80
0c+pzSj64ww1vlNTASMzP2aVdlCFVGh49YqYpMaoR4bBssjBo8ncRuyNtqeypLh1
AmYClYv1cnAM8Atn1oaEC70jg+K4knOMoNlBKmb3dnIeAhK/5WbnBz23GsI1evuQ
UysUU6qxGB4a+rQeqw7P6W8R8F8VystE8P/ISMie18Akyu5jHg89UcnLt62hN9aB
IJuzcf4vmu32Ezv6BCxU3sh5/9fZfQJRZqNswLQnEdzponzooayH/MFyJ4kP6Mw2
U4Wg0dDU/fJJr8hB2fHNcJjFt4O8FoJK/fq9HuLYSoA/ggJvbyKgQubXUXDAC4j3
uqNS3e8f+OGU9P1i061SqOdxyUYt9HtU+mbSRhN843vaH4vzd5SOe55YsldoBtnX
ATfe18dhmHsCmZN4Mvpht5A4LUAleHT8n70wMunYm7XlPhT5cknKqZ7bpq1mfqXp
kdR1K4lr8etUSbrzQw9XJNLD6b0LpvvuhX55enDj5iYk1j1fo943bJ8teQwNBKoR
Y7MQ1vo0Z78D2C8tIMEUMTf1wqq5l1z55l6oIKHZa+gZae+3NngwilgbaeWGtbYc
BSmMOm/IHk/pEcF4IU0l401NpuqL/0/Hk/qlJJK94Fw4eBaaCqo=
=YTM4
-----END PGP SIGNATURE-----