From d3ee5d70a4d943ba5ce11981b4d723e948970a17 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Mon, 4 Nov 2013 14:33:33 +0000 Subject: Check UTF-8-ness of shortstrs in non-content-bearing methods. Note that we use the previously developed "fast" checker to avoid a dependency on xmerl, not so much because it is fast. --- codegen.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'codegen.py') diff --git a/codegen.py b/codegen.py index 842549cf..91fa1154 100644 --- a/codegen.py +++ b/codegen.py @@ -187,7 +187,7 @@ def genErl(spec): elif type == 'table': return p+'Len:32/unsigned, '+p+'Tab:'+p+'Len/binary' - def genFieldPostprocessing(packed): + def genFieldPostprocessing(packed, hasContent): for f in packed: type = erlType(f.domain) if type == 'bit': @@ -199,6 +199,10 @@ def genErl(spec): elif type == 'table': print " F%d = rabbit_binary_parser:parse_table(F%dTab)," % \ (f.index, f.index) + # We skip the check on content-bearing methods for + # speed. This is a sanity check, not a security thing. + elif type == 'shortstr' and not hasContent: + print " rabbit_binary_parser:assert_utf8(F%d)," % (f.index) else: pass @@ -214,7 +218,7 @@ def genErl(spec): restSeparator = '' recordConstructorExpr = '#%s{%s}' % (m.erlangName(), fieldMapList(m.arguments)) print "decode_method_fields(%s, <<%s>>) ->" % (m.erlangName(), binaryPattern) - genFieldPostprocessing(packedFields) + genFieldPostprocessing(packedFields, m.hasContent) print " %s;" % (recordConstructorExpr,) def genDecodeProperties(c): -- cgit v1.2.1