summaryrefslogtreecommitdiff
path: root/core/variant
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-30 15:43:01 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-30 16:13:43 +0200
commit324636473aa65165caeee29e9b70e2d8c21fcb96 (patch)
tree505d93035a7c82f317b9315feff47029f35663da /core/variant
parente95e33f25137486d2df0a1c13e17394454c7fdf1 (diff)
[Net] Fix Marshalls infinite recursion crash.
Variants like dictionaries and arrays can have cyclic references, which caused `encode_variant` to run an infinite recursion. Instead of keeping a stack and looking for cyclic references which would make serialization slower, this commit adds a `MAX_RECURSION_DEPTH` constant to Variant, and have `encode_variant` keep track of the current recursion depth, bailing when it's too high since this likely means a cyclic reference has been encountered.
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/variant.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 4dc706e853..780f9b4e70 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -118,6 +118,11 @@ public:
VARIANT_MAX
};
+ enum {
+ // Maximum recursion depth allowed when serializing variants.
+ MAX_RECURSION_DEPTH = 1024,
+ };
+
private:
friend struct _VariantCall;
friend class VariantInternal;