mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 13:06:14 +01:00
gvariant-serialiser: Prevent unbounded recursion in is_normal()
This fixes a bug in 7c4e6e9fbe
.
The original approach in that commit accidentally only checked the depth
at the leaf nodes in the variant tree, whereas actually the depth should
be checked before recursing to avoid stack overflow.
It neglected to consider that `g_variant_serialised_is_normal()` would
be recursed into by some of the `DISPATCH(_is_normal)` cases. When that
happened, the depth check was after the recursion so couldn’t prevent a
stack overflow.
Fixes: #2572
This commit is contained in:
parent
3fb62e4984
commit
1ce8a0abb7
@ -1587,6 +1587,9 @@ g_variant_serialised_byteswap (GVariantSerialised serialised)
|
||||
gboolean
|
||||
g_variant_serialised_is_normal (GVariantSerialised serialised)
|
||||
{
|
||||
if (serialised.depth >= G_VARIANT_MAX_RECURSION_DEPTH)
|
||||
return FALSE;
|
||||
|
||||
DISPATCH_CASES (serialised.type_info,
|
||||
|
||||
return gvs_/**/,/**/_is_normal (serialised);
|
||||
@ -1595,8 +1598,6 @@ g_variant_serialised_is_normal (GVariantSerialised serialised)
|
||||
|
||||
if (serialised.data == NULL)
|
||||
return FALSE;
|
||||
if (serialised.depth >= G_VARIANT_MAX_RECURSION_DEPTH)
|
||||
return FALSE;
|
||||
|
||||
/* some hard-coded terminal cases */
|
||||
switch (g_variant_type_info_get_type_char (serialised.type_info))
|
||||
|
Loading…
Reference in New Issue
Block a user