This is an automated email from the git hooks/post-receive script.
nickm pushed a commit to branch main in repository trunnel.
commit 6ab21f0f9315dbe5ee74b5737a0d87276cad980c Author: Nick Mathewson nickm@torproject.org AuthorDate: Thu May 5 08:43:11 2022 -0400
Do not generate a `truncated:` for _parsing_ u8[] at end of struct
Our previous rule had been that all u8 arrays needed a `truncated:` section. That's fine if the arrays have a length, but not if their length extends to the end of the structure: such arrays can't be truncated.
This time I also add a test to make sure change works. --- lib/trunnel/CodeGen.py | 3 ++- test/valid/end_of_struct.trunnel | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/trunnel/CodeGen.py b/lib/trunnel/CodeGen.py index e7ad11c..f7a8ca3 100644 --- a/lib/trunnel/CodeGen.py +++ b/lib/trunnel/CodeGen.py @@ -2632,7 +2632,8 @@ class ParseFnGenerator(CodeGenerator):
elt = "obj->%s.elts_" % sva.c_name
- self.needLabels.add(self.truncatedLabel) + if sva.widthfield != None: + self.needLabels.add(self.truncatedLabel)
if str(sva.basetype) == 'char': tp = "char" diff --git a/test/valid/end_of_struct.trunnel b/test/valid/end_of_struct.trunnel new file mode 100644 index 0000000..4c5e7b3 --- /dev/null +++ b/test/valid/end_of_struct.trunnel @@ -0,0 +1,4 @@ + +struct simple_body { + u8 body[]; +} \ No newline at end of file