1
0
mirror of https://github.com/golang/go synced 2024-11-15 01:10:21 -07:00
go/src/bytes
Michael Munday af06e65910 [release-branch.go1.15] bytes, internal/bytealg: fix incorrect IndexString usage
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 #41595.

Change-Id: I81d88cf8c5ae143a8f5f460d18f8269cb6c0f28c
Reviewed-on: https://go-review.googlesource.com/c/go/+/256921
Trust: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-07 21:02:58 +00:00
..
boundary_test.go bytes: reduce work in IndexNearPageBoundary test 2017-11-04 11:09:49 +00:00
buffer_test.go bytes: deflake TestGrow by using testing.AllocsPerRun 2020-02-26 18:40:56 +00:00
buffer.go bytes: remove obsolete comment 2019-05-28 02:52:39 +00:00
bytes_test.go strings, bytes: improve IndexAny and LastIndexAny performance 2020-03-11 05:13:13 +00:00
bytes.go [release-branch.go1.15] bytes, internal/bytealg: fix incorrect IndexString usage 2020-10-07 21:02:58 +00:00
compare_test.go bytes: add endian base compare test 2019-10-07 14:49:57 +00:00
example_test.go bytes: add examples for ToTitleSpecial, ToUpperSpecial and ToLowerSpecial 2019-03-01 14:56:41 +00:00
export_test.go bytes, internal/bytealg: simplify Equal 2019-04-24 00:56:36 +00:00
reader_test.go bytes, strings: fix Reader.UnreadRune returning without error on a zero Reader 2018-10-29 20:07:25 +00:00
reader.go bytes, strings: fix Reader.UnreadRune returning without error on a zero Reader 2018-10-29 20:07:25 +00:00