• Didier Spezia's avatar
    cmd/asm: fix another infinite loop in register list parser · 63e2bed0
    Didier Spezia authored
    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/14314Reviewed-by: 's avatarRob Pike <r@golang.org>
    63e2bed0
Name
Last commit
Last update
..
internal Loading commit data...
main.go Loading commit data...