aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-01-24 10:51:38 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-01-24 10:53:21 +0100
commit40723a067e2216f643485b732f90202b38b59e4b (patch)
tree17d39b5d4804223ea592855885abfd3919e95077 /prog/encodingexec.go
parent40c6a8ebf50872036d42c06e2e7a19b973539860 (diff)
prog: validate deserialized programs
The optimization change removed validation too aggressively. We do need program validation during deserialization, because we can get bad programs from corpus or hub. Restore program validation after deserialization.
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go
index 5afd83fd6..304440d0e 100644
--- a/prog/encodingexec.go
+++ b/prog/encodingexec.go
@@ -35,8 +35,10 @@ const (
// SerializeForExec serializes program p for execution by process pid into the provided buffer.
// If the provided buffer is too small for the program an error is returned.
func (p *Prog) SerializeForExec(buffer []byte, pid int) error {
- if err := p.validate(); err != nil {
- panic(fmt.Errorf("serializing invalid program: %v", err))
+ if debug {
+ if err := p.validate(); err != nil {
+ panic(fmt.Errorf("serializing invalid program: %v", err))
+ }
}
var instrSeq uintptr
w := &execContext{