• Didier Spezia's avatar
    [release-branch.go1.5] cmd/asm: fix potential infinite loop in parser · 97ec0a81
    Didier Spezia authored
    For ARM machines, the assembler supports list of registers
    operands such as [R1,R2].
    
    A list missing a ']' results in the parser issuing many errors
    and consuming all the tokens. At EOF (i.e. end of the line),
    it still loops.
    
    Normally, a counter is maintained to make sure the parser
    stops after 10 errors. However, multiple errors occuring on the
    same line are simply ignored. Only the first one is reported.
    At most one error per line is accounted.
    
    Missing ']' in a register list therefore results in an
    infinite loop.
    
    Fixed the parser by explicitly checking for ']' to interrupt
    this loops
    
    In the operand tests, also fixed a wrong entry which I think was
    not set on purpose (but still led to a successful result).
    
    Fixes #11764
    
    Change-Id: Ie87773388ee0d21b3a2a4cb941d4d911d0230ba4
    Reviewed-on: https://go-review.googlesource.com/13920Reviewed-by: default avatarRob Pike <r@golang.org>
    Reviewed-on: https://go-review.googlesource.com/14225
    97ec0a81
operand_test.go 10.3 KB