summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2019-03-28 13:42:48 -0700
committerShentubot <shentubot@google.com>2019-03-28 13:43:47 -0700
commite373d3642e95768229f0414fe164beeb13170817 (patch)
tree16814bd44b6d04e99b1fdc413e88dee1ad95cbd8 /pkg
parentf005350c93cb9e2a247b0d8a061e52f3160d36d4 (diff)
Internal change.
PiperOrigin-RevId: 240842801 Change-Id: Ibbd6f849f9613edc1b1dd7a99a97d1ecdb6e9188
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/fs/proc/uid_gid_map.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/sentry/fs/proc/uid_gid_map.go b/pkg/sentry/fs/proc/uid_gid_map.go
index d6e278f79..a52e0cb1f 100644
--- a/pkg/sentry/fs/proc/uid_gid_map.go
+++ b/pkg/sentry/fs/proc/uid_gid_map.go
@@ -134,10 +134,23 @@ func (imfo *idMapFileOperations) Write(ctx context.Context, file *fs.File, src u
if _, err := src.CopyIn(ctx, b); err != nil {
return 0, err
}
- lines := bytes.SplitN(bytes.TrimSpace(b), []byte("\n"), maxIDMapLines+1)
+
+ // Truncate from the first NULL byte.
+ var nul int64
+ nul = int64(bytes.IndexByte(b, 0))
+ if nul == -1 {
+ nul = srclen
+ }
+ b = b[:nul]
+ // Remove the last \n.
+ if nul >= 1 && b[nul-1] == '\n' {
+ b = b[:nul-1]
+ }
+ lines := bytes.SplitN(b, []byte("\n"), maxIDMapLines+1)
if len(lines) > maxIDMapLines {
return 0, syserror.EINVAL
}
+
entries := make([]auth.IDMapEntry, len(lines))
for i, l := range lines {
var e auth.IDMapEntry