From a4b8819948b5c659dca6841dbb92cb2dad65ed19 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 31 Jan 2023 12:14:41 -0800 Subject: [PATCH] increase rundata size limits --- pkg/shexec/shexec.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/shexec/shexec.go b/pkg/shexec/shexec.go index bf19c92b..bfa3a541 100644 --- a/pkg/shexec/shexec.go +++ b/pkg/shexec/shexec.go @@ -45,6 +45,8 @@ const DefaultTermType = "xterm-256color" const DefaultMaxPtySize = 1024 * 1024 const MinMaxPtySize = 16 * 1024 const MaxMaxPtySize = 100 * 1024 * 1024 +const MaxRunDataSize = 1024 * 1024 +const MaxTotalRunDataSize = 10 * MaxRunDataSize const GetStateTimeout = 5 * time.Second @@ -385,12 +387,12 @@ func ValidateRunPacket(pk *packet.RunPacketType) error { } totalRunData := 0 for _, rd := range pk.RunData { - if rd.DataLen > mpio.ReadBufSize { + if rd.DataLen > MaxRunDataSize { return fmt.Errorf("cannot detach command, constant rundata input too large fd=%d, len=%d, max=%d", rd.FdNum, rd.DataLen, mpio.ReadBufSize) } totalRunData += rd.DataLen } - if totalRunData > mpio.MaxTotalRunDataSize { + if totalRunData > MaxTotalRunDataSize { return fmt.Errorf("cannot detach command, constant rundata input too large len=%d, max=%d", totalRunData, mpio.MaxTotalRunDataSize) } } @@ -618,8 +620,8 @@ func (opts *ClientOpts) MakeRunPacket() (*packet.RunPacketType, error) { } func AddRunData(pk *packet.RunPacketType, data string, dataType string) (int, error) { - if len(data) > mpio.ReadBufSize { - return 0, fmt.Errorf("%s too large, exceeds read buffer size", dataType) + if len(data) > MaxRunDataSize { + return 0, fmt.Errorf("%s too large, exceeds read buffer size size:%d", dataType, len(data)) } fdNum, err := NextFreeFdNum(pk) if err != nil {