Skip to content
Snippets Groups Projects
  • Michael Munday's avatar
    11cdbab9
    bytes, internal/bytealg: fix incorrect IndexString usage · 11cdbab9
    Michael Munday authored
    The IndexString implementation in the bytealg package requires that
    the string passed into it be in the range '2 <= len(s) <= MaxLen'
    where MaxLen may be any value (including 0).
    
    CL 156998 added calls to bytealg.IndexString where MaxLen was not
    first checked. This led to an illegal instruction on s390x with
    the vector facility disabled.
    
    This CL guards the calls to bytealg.IndexString with a MaxLen check.
    If the check fails then the code now falls back to the pre CL 156998
    implementation (a loop over the runes in the string).
    
    Since the MaxLen check is now in place the generic implementation is
    no longer called so I have returned it to its original unimplemented
    state.
    
    In future we may want to drop MaxLen to prevent this kind of
    confusion.
    
    Fixes #41552.
    
    Change-Id: Ibeb3f08720444a05c08d719ed97f6cef2423bbe9
    Reviewed-on: https://go-review.googlesource.com/c/go/+/256717
    
    
    Run-TryBot: Michael Munday <mike.munday@ibm.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Michael Munday <mike.munday@ibm.com>
    Reviewed-by: default avatarKeith Randall <khr@golang.org>
    11cdbab9
    History
    bytes, internal/bytealg: fix incorrect IndexString usage
    Michael Munday authored
    The IndexString implementation in the bytealg package requires that
    the string passed into it be in the range '2 <= len(s) <= MaxLen'
    where MaxLen may be any value (including 0).
    
    CL 156998 added calls to bytealg.IndexString where MaxLen was not
    first checked. This led to an illegal instruction on s390x with
    the vector facility disabled.
    
    This CL guards the calls to bytealg.IndexString with a MaxLen check.
    If the check fails then the code now falls back to the pre CL 156998
    implementation (a loop over the runes in the string).
    
    Since the MaxLen check is now in place the generic implementation is
    no longer called so I have returned it to its original unimplemented
    state.
    
    In future we may want to drop MaxLen to prevent this kind of
    confusion.
    
    Fixes #41552.
    
    Change-Id: Ibeb3f08720444a05c08d719ed97f6cef2423bbe9
    Reviewed-on: https://go-review.googlesource.com/c/go/+/256717
    
    
    Run-TryBot: Michael Munday <mike.munday@ibm.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Michael Munday <mike.munday@ibm.com>
    Reviewed-by: default avatarKeith Randall <khr@golang.org>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.