From 4cd91fc0b5007710bf0f38de6319ce24c31a52e5 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 15 Apr 2024 14:54:59 +0200 Subject: pkg/ipc: pass only exec encoding to Exec Does not require passing text program to ipc.Env.Exec. Make it possible to provide just the exec encoding. This requires moving fallback coverage to the host since it need the program. --- prog/encodingexec.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 40cfc9592..fb8e5fbaf 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -23,7 +23,6 @@ package prog import ( "encoding/binary" - "errors" "fmt" "reflect" "sort" @@ -63,8 +62,6 @@ const ( execMaxCommands = 1000 // executor knows about this constant (kMaxCommands) ) -var ErrExecBufferTooSmall = errors.New("encodingexec: provided buffer is too small") - // SerializeForExec serializes program p for execution by process pid into the provided buffer. // Returns number of bytes written to the buffer. // If the provided buffer is too small for the program an error is returned. @@ -81,8 +78,11 @@ func (p *Prog) SerializeForExec() ([]byte, error) { w.serializeCall(c) } w.write(execInstrEOF) - if len(w.buf) > ExecBufferSize || w.copyoutSeq > execMaxCommands { - return nil, ErrExecBufferTooSmall + if len(w.buf) > ExecBufferSize { + return nil, fmt.Errorf("encodingexec: too large program (%v/%v)", len(w.buf), ExecBufferSize) + } + if w.copyoutSeq > execMaxCommands { + return nil, fmt.Errorf("encodingexec: too many resources (%v/%v)", w.copyoutSeq, execMaxCommands) } return w.buf, nil } -- cgit mrf-deployment