]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.5] cmd/asm: fix potential infinite loop in parser
authorDidier Spezia <didier.06@gmail.com>
Tue, 25 Aug 2015 16:25:11 +0000 (16:25 +0000)
committerAndrew Gerrand <adg@golang.org>
Tue, 8 Sep 2015 05:41:28 +0000 (05:41 +0000)
commit97ec0a816bfe1f8488355b5a6e94907a993b2cc7
tree54d5793febc72f4eb2111af469bde289abb5a9f4
parent2dfb0eb6c296e1d77a4d6fbd8ee7ce50a2379825
[release-branch.go1.5] cmd/asm: fix potential infinite loop in parser

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/13920
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-on: https://go-review.googlesource.com/14225
src/cmd/asm/internal/asm/operand_test.go
src/cmd/asm/internal/asm/parse.go