mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
gstrfuncs: Add g_memdup2() function
This will replace the existing `g_memdup()` function, which has an unavoidable security flaw of taking its `byte_size` argument as a `guint` rather than as a `gsize`. Most callers will expect it to be a `gsize`, and may pass in large values which could silently be truncated, resulting in an undersize allocation compared to what the caller expects. This could lead to a classic buffer overflow vulnerability for many callers of `g_memdup()`. `g_memdup2()`, in comparison, takes its `byte_size` as a `gsize`. Spotted by Kevin Backhouse of GHSL. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: GHSL-2021-045 Helps: #2319
This commit is contained in:
@@ -1341,6 +1341,7 @@ g_newa
|
||||
<SUBSECTION>
|
||||
g_memmove
|
||||
g_memdup
|
||||
g_memdup2
|
||||
|
||||
<SUBSECTION>
|
||||
GMemVTable
|
||||
|
Reference in New Issue
Block a user