summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-01-29 02:00:48 +0000
committergVisor bot <gvisor-bot@google.com>2021-01-29 02:00:48 +0000
commita96f13ff5a34ceba128ce91a0f1926004401859a (patch)
treeede6cc4a0f75bfd27104f8a6bf8bfcb898ef377e /pkg/sentry
parent55430eb7d2cae50a0572383799b3ca6766a74423 (diff)
parentc99e092a3bb986b03fd85d426e166ef2c73a8c51 (diff)
Merge release-20210125.0-20-gc99e092a3 (automated)
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/socket/netstack/netstack.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 3115a227d..30a31ef4c 100644
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -459,17 +459,24 @@ func (s *SocketOperations) Write(ctx context.Context, _ *fs.File, src usermem.IO
var _ tcpip.Payloader = (*limitedPayloader)(nil)
type limitedPayloader struct {
- io.LimitedReader
+ inner io.LimitedReader
+ err error
}
-func (l limitedPayloader) Len() int {
- return int(l.N)
+func (l *limitedPayloader) Read(p []byte) (int, error) {
+ n, err := l.inner.Read(p)
+ l.err = err
+ return n, err
+}
+
+func (l *limitedPayloader) Len() int {
+ return int(l.inner.N)
}
// ReadFrom implements fs.FileOperations.ReadFrom.
func (s *SocketOperations) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader, count int64) (int64, error) {
f := limitedPayloader{
- LimitedReader: io.LimitedReader{
+ inner: io.LimitedReader{
R: r,
N: count,
},
@@ -480,7 +487,7 @@ func (s *SocketOperations) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader
Atomic: true,
})
if err == tcpip.ErrBadBuffer {
- err = nil
+ return n, f.err
}
return n, syserr.TranslateNetstackError(err).ToError()
}