diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2017-08-01 18:30:20 +0200 |
|---|---|---|
| committer | Andrey Konovalov <andreyknvl@google.com> | 2017-08-01 18:38:20 +0200 |
| commit | 1172db0ccf077bbfef7ddd176ced61c7140cb698 (patch) | |
| tree | d488163d92a1212d94bb8f6f65be7e9b8172cb7e /prog | |
| parent | 0b4392111b2785bac5b780848a5a88cc87bfd419 (diff) | |
prog: fix encoding for exec of result args
ResultArg might have const value.
Also add a test.
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/encodingexec.go | 18 | ||||
| -rw-r--r-- | prog/encodingexec_test.go | 7 |
2 files changed, 20 insertions, 5 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go index ba2efcd37..403b09f88 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -253,11 +253,19 @@ func (w *execContext) writeArg(arg Arg, pid int, csumMap map[Arg]CsumInfo) { w.write(a.Type().BitfieldOffset()) w.write(a.Type().BitfieldLength()) case *ResultArg: - w.write(ExecArgResult) - w.write(a.Size()) - w.write(w.args[a.Res].Idx) - w.write(a.OpDiv) - w.write(a.OpAdd) + if a.Res == nil { + w.write(ExecArgConst) + w.write(a.Size()) + w.write(a.Val) + w.write(0) // bit field offset + w.write(0) // bit field length + } else { + w.write(ExecArgResult) + w.write(a.Size()) + w.write(w.args[a.Res].Idx) + w.write(a.OpDiv) + w.write(a.OpAdd) + } case *PointerArg: w.write(ExecArgConst) w.write(a.Size()) diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go index b7a6b9463..2d96a47e0 100644 --- a/prog/encodingexec_test.go +++ b/prog/encodingexec_test.go @@ -250,6 +250,13 @@ func TestSerializeForExec(t *testing.T) { instrEOF, }, }, + { + "syz_test$res1(0xffff)", + []uint64{ + callID("syz_test$res1"), 1, argConst, 4, 0xffff, 0, 0, + instrEOF, + }, + }, } buf := make([]byte, ExecBufferSize) |
