diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-30 17:27:04 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-30 17:27:04 +0000 |
commit | 2829b90acddad106f58cf10a65a212cd3ac6c81e (patch) | |
tree | 23fd9c6e2ca2275738ac92b4f5086166dfe5eb3e /pkg/sentry/fs | |
parent | 32db0c936ba044c22cefda06b00fba1119d24a67 (diff) | |
parent | ede8dfab3760afc8063c3418f217e52f7ec70d42 (diff) |
Merge release-20200127.0-35-gede8dfa (automated)
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r-- | pkg/sentry/fs/tmpfs/inode_file.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/sentry/fs/tmpfs/inode_file.go b/pkg/sentry/fs/tmpfs/inode_file.go index dabc10662..25abbc151 100644 --- a/pkg/sentry/fs/tmpfs/inode_file.go +++ b/pkg/sentry/fs/tmpfs/inode_file.go @@ -17,6 +17,7 @@ package tmpfs import ( "fmt" "io" + "math" "time" "gvisor.dev/gvisor/pkg/abi/linux" @@ -444,10 +445,15 @@ func (rw *fileReadWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error) defer rw.f.dataMu.Unlock() // Compute the range to write. - end := fs.WriteEndOffset(rw.offset, int64(srcs.NumBytes())) - if end == rw.offset { // srcs.NumBytes() == 0? + if srcs.NumBytes() == 0 { + // Nothing to do. return 0, nil } + end := fs.WriteEndOffset(rw.offset, int64(srcs.NumBytes())) + if end == math.MaxInt64 { + // Overflow. + return 0, syserror.EINVAL + } // Check if seals prevent either file growth or all writes. switch { |