[issue11105] Compiling evil ast crashes interpreter
Batuhan
report at bugs.python.org
Sat Dec 28 12:41:12 EST 2019
Batuhan <batuhanosmantaskaya at gmail.com> added the comment:
We can probably implement something like this to prevent this happening
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index daac0966f5..f9da52da7f 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -559,6 +559,11 @@ class Obj2ModVisitor(PickleVisitor):
self.emit("asdl_seq_SET(%s, i, val);" % field.name, depth+2)
self.emit("}", depth+1)
else:
+ self.emit("if (obj == tmp) {", depth+1)
+ self.emit("PyErr_SetString(PyExc_RuntimeError, \"Recursing fields "
+ "are not supported for AST nodes.\");", depth+2, reflow=False)
+ self.emit("goto failed;", depth+2)
+ self.emit("}", depth+1)
self.emit("res = obj2ast_%s(tmp, &%s, arena);" %
(field.type, field.name), depth+1)
self.emit("if (res != 0) goto failed;", depth+1)
----------
nosy: +BTaskaya
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue11105>
_______________________________________
More information about the Python-bugs-list
mailing list