]> Cypherpunks repositories - gostls13.git/commit
cmd/asm: fix another infinite loop in register list parser
authorDidier Spezia <didier.06@gmail.com>
Sat, 5 Sep 2015 11:28:33 +0000 (11:28 +0000)
committerRob Pike <r@golang.org>
Sat, 5 Sep 2015 18:57:11 +0000 (18:57 +0000)
commit63e2bed0ab93e6116b552453e45c0322777508f9
treedd527f9608f96bc58fa8b99b2e5dd5e735669deb
parent22452ac5924faaf95ecb49fb345fea3fdd783bb6
cmd/asm: fix another infinite loop in register list parser

The code parsing register lists involves an inner loop on
each range defined by the lo,hi bounds. The condition on
this loop (for lo<=hi) is fragile, because the bounds
are unsigned 16 bits numbers.

In some corner cases, the calculated upper bound is 2^16-1
leading to an infinite loop.

Parsing operand `[):[o-FP` results in:
- an infinite loop for non ARM architectures
- the generation of almost 2^16 errors for the ARM architecture
  (which are then ignored)

This CL improves the code in 3 ways:
- bail out early when parsing non R prefixed registers
- make sure the register index is never negative
- make sure the number of iterations is limited by the
  maximum size of the range (as a defensive measure).

Fixes #12469

Change-Id: Ib1e7e36fb8ad5a3a52c50fc6219d3cfe2b39cc34
Reviewed-on: https://go-review.googlesource.com/14314
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/asm/internal/asm/operand_test.go
src/cmd/asm/internal/asm/parse.go