Fix possible infinite loop in delocate.go.
I had a brain-fart and had in mind that strings.Index(x[i:], _) would
return a value relative to the beginning of |x|, which is impossible.
Change-Id: I905ea1fa3469ea13f2e3b782c4baf2431b615a2f
Reviewed-on: https://boringssl-review.googlesource.com/15146
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/fipsmodule/delocate.go b/crypto/fipsmodule/delocate.go
index d8b5fb3..12100dc 100644
--- a/crypto/fipsmodule/delocate.go
+++ b/crypto/fipsmodule/delocate.go
@@ -382,7 +382,10 @@
for _, line := range contents {
for symbol, mappedSymbol := range localSymbols {
- for i := strings.Index(line, symbol); i >= 0; i = strings.Index(line[i:], symbol) {
+ i := 0
+ for match := strings.Index(line, symbol); match >= 0; match = strings.Index(line[i:], symbol) {
+ i += match
+
before := ' '
if i > 0 {
before, _ = utf8.DecodeLastRuneInString(line[:i])