This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch releases-0.12 in repository https://gitbox.apache.org/repos/asf/fory.git
commit 6c87ed5b2b66eccf76855eb05366472549c6f53a Author: chaokunyang <[email protected]> AuthorDate: Wed Sep 17 23:54:12 2025 +0800 add missing methods --- python/pyfory/_fory.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/pyfory/_fory.py b/python/pyfory/_fory.py index 76ef34e72..60562f9b4 100644 --- a/python/pyfory/_fory.py +++ b/python/pyfory/_fory.py @@ -490,6 +490,20 @@ class Fory: def read_ref_pyobject(self, buffer): return self.deserialize_ref(buffer) + def inc_depth(self): + self.depth += 1 + if self.depth > self.max_depth: + self.throw_depth_limit_exceeded_exception() + + def dec_depth(self): + self.depth -= 1 + + def throw_depth_limit_exceeded_exception(self): + raise Exception( + f"Read depth exceed max depth: {self.depth}, the deserialization data may be malicious. If it's not malicious, " + "please increase max read depth by Fory(..., max_depth=...)" + ) + def reset_write(self): self.ref_resolver.reset_write() self.type_resolver.reset_write() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
