mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
gwin32appinfo: Fix an incorrect size vs wide-length comparison
`value_size` is in bytes, whereas `ms_resource_prefix_len` is in wide characters, so they cannot be compared directly. This meant that if 12 ≤ `value_size` < 24 then the call to `memcmp()` would read off the end of `value`. Fix it by using a wide-character and nul-aware comparison function and operating only on wide-lengths. This is safe because `g_win32_registry_key_get_value_w()` guarantees that string-typed return values are nul-terminated. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3649
This commit is contained in:
@@ -3669,10 +3669,7 @@ grab_registry_string (GWin32RegistryKey *handler_appkey,
|
||||
|
||||
/* There's no way for us to resolve "ms-resource:..." strings */
|
||||
if (value != NULL &&
|
||||
value_size >= ms_resource_prefix_len &&
|
||||
memcmp (value,
|
||||
ms_resource_prefix,
|
||||
ms_resource_prefix_len * sizeof (gunichar2)) == 0)
|
||||
wcsncmp (value, ms_resource_prefix, ms_resource_prefix_len) == 0)
|
||||
g_clear_pointer (&value, g_free);
|
||||
|
||||
if (value == NULL)
|
||||
|
Reference in New Issue
Block a user