aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-15 14:54:59 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-16 14:20:36 +0000
commit4cd91fc0b5007710bf0f38de6319ce24c31a52e5 (patch)
tree025210f316d065a63e680a054ab04c017ebc7315 /prog/encodingexec.go
parent7e9780e93983e03547322aab489429ae4a7d2fa3 (diff)
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.
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go10
1 files changed, 5 insertions, 5 deletions
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
}