diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2022-01-07 16:42:14 +0000 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@redhat.com> | 2023-03-24 08:54:44 -0500 |
commit | 98d5b84c2cdff1431084909b47d1a7f6d0dd60b5 (patch) | |
tree | 9bbf5f644e4eb9939d59f84542f2539cf8afa9e7 | |
parent | a4ddf8ea87a43c2ceffb5d806061d9c6297b9096 (diff) | |
download | glib-98d5b84c2cdff1431084909b47d1a7f6d0dd60b5.tar.gz |
gvariant: Don’t allow child elements of a tuple to overlap each other
This is similar to the earlier commit which prevents child elements of a
variable-sized array from overlapping each other, but this time for
tuples. It is based heavily on ideas by William Manley.
Tuples are slightly different from variable-sized arrays in that they
contain a mixture of fixed and variable sized elements. All but one of
the variable sized elements have an entry in the frame offsets table.
This means that if we were to just check the ordering of the frame
offsets table, the variable sized elements could still overlap
interleaving fixed sized elements, which would be bad.
Therefore we have to check the elements rather than the frame offsets.
The logic of checking the elements up to the index currently being
requested, and caching the result in `ordered_offsets_up_to`, means that
the algorithmic cost implications are the same for this commit as for
variable-sized arrays: an O(N) cost for these checks is amortised out
over N accesses to O(1) per access.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2121
-rw-r--r-- | glib/gvariant-core.c | 2 | ||||
-rw-r--r-- | glib/tests/gvariant.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/glib/gvariant-core.c b/glib/gvariant-core.c index 9b268d977..c6c50a6ff 100644 --- a/glib/gvariant-core.c +++ b/glib/gvariant-core.c @@ -3,6 +3,8 @@ * Copyright © 2010 Codethink Limited * Copyright © 2022 Endless OS Foundation, LLC * + * SPDX-License-Identifier: LGPL-2.1-or-later + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c index 9ed56d66d..a565ea69a 100644 --- a/glib/tests/gvariant.c +++ b/glib/tests/gvariant.c @@ -3,6 +3,8 @@ * Copyright © 2020 William Manley * Copyright © 2022 Endless OS Foundation, LLC * + * SPDX-License-Identifier: LGPL-2.1-or-later + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either |