mirror of
https://github.com/golang/go
synced 2024-11-23 08:10:03 -07:00
archive/tar: narrow trim range for formatter'formatString
Trim s[:len(b)-1] rather than s[:len(b)], since s[len(b)-1] is '/'.
Change-Id: I055da555810c112774549bd13d4faa8bfa0a60dc
GitHub-Last-Rev: 457977514d
GitHub-Pull-Request: golang/go#60729
Reviewed-on: https://go-review.googlesource.com/c/go/+/502376
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
d4b46b0956
commit
840ec052f6
@ -73,7 +73,7 @@ func (f *formatter) formatString(b []byte, s string) {
|
||||
// in the V7 path field as a directory even though the full path
|
||||
// recorded elsewhere (e.g., via PAX record) contains no trailing slash.
|
||||
if len(s) > len(b) && b[len(b)-1] == '/' {
|
||||
n := len(strings.TrimRight(s[:len(b)], "/"))
|
||||
n := len(strings.TrimRight(s[:len(b)-1], "/"))
|
||||
b[n] = 0 // Replace trailing slash with NUL terminator
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user