summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-09-28 00:47:24 +0000
committergVisor bot <gvisor-bot@google.com>2019-09-28 00:47:24 +0000
commit58d4085eb7ee61b829607ae959e5b7b1d67a737a (patch)
treea86463fa5ed90afd08a38078349fc627c777d301 /pkg
parent0c313e7e72af00e51c8e17e8fa0b02efd4c0d592 (diff)
parenteebc38be7a0de0ea7ae84e48949c1a94b3284b7e (diff)
Merge release-20190806.1-207-geebc38b (automated)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/usermem/usermem.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/sentry/usermem/usermem.go b/pkg/sentry/usermem/usermem.go
index 6eced660a..7b1f312b1 100644
--- a/pkg/sentry/usermem/usermem.go
+++ b/pkg/sentry/usermem/usermem.go
@@ -16,6 +16,7 @@
package usermem
import (
+ "bytes"
"errors"
"io"
"strconv"
@@ -270,11 +271,10 @@ func CopyStringIn(ctx context.Context, uio IO, addr Addr, maxlen int, opts IOOpt
n, err := uio.CopyIn(ctx, addr, buf[done:done+readlen], opts)
// Look for the terminating zero byte, which may have occurred before
// hitting err.
- for i, c := range buf[done : done+n] {
- if c == 0 {
- return stringFromImmutableBytes(buf[:done+i]), nil
- }
+ if i := bytes.IndexByte(buf[done:done+n], byte(0)); i >= 0 {
+ return stringFromImmutableBytes(buf[:done+i]), nil
}
+
done += n
if err != nil {
return stringFromImmutableBytes(buf[:done]), err