aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prog/mutation_test.go4
-rw-r--r--prog/validation.go3
2 files changed, 5 insertions, 2 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 3ff30d1e9..d81ddb33b 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -117,11 +117,11 @@ func TestMutateTable(t *testing.T) {
// Extend an array.
{
"r0 = open(&(0x7f0000001000)=\"2e2f66696c653000\", 0x22c0, 0x1)\n" +
- "readv(r0, &(0x7f0000000000)=[{&(0x7f0000001000)=nil, 0x1}, {&(0x7f0000002000)=nil, 0x2}], 0x2)\n",
+ "readv(r0, &(0x7f0000000000)=[{&(0x7f0000001000)=\"00\", 0x1}, {&(0x7f0000002000)=\"00\", 0x2}], 0x2)\n",
"mmap(&(0x7f0000000000/0x1000)=nil, (0x1000), 0x3, 0x32, 0xffffffffffffffff, 0x0)\n" +
"r0 = open(&(0x7f0000001000)=\"2e2f66696c653000\", 0x22c0, 0x1)\n" +
- "readv(r0, &(0x7f0000000000)=[{&(0x7f0000001000)=nil, 0x1}, {&(0x7f0000002000)=nil, 0x2}, {&(0x7f0000000000)=nil, 0x3}], 0x3)\n",
+ "readv(r0, &(0x7f0000000000)=[{&(0x7f0000001000)=\"00\", 0x1}, {&(0x7f0000002000)=\"00\", 0x2}, {&(0x7f0000000000)=\"00\", 0x3}], 0x3)\n",
},
}
rs, _ := initTest(t)
diff --git a/prog/validation.go b/prog/validation.go
index 93bc94170..a1b68ba1b 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -124,6 +124,9 @@ func (c *Call) validate(ctx *validCtx) error {
return fmt.Errorf("syscall %v: vma arg '%v' has size 0", c.Meta.Name, typ.Name())
}
case sys.PtrType:
+ if arg.Res == nil && !typ.Optional() {
+ return fmt.Errorf("syscall %v: non optional pointer arg '%v' is nil", c.Meta.Name, typ.Name())
+ }
if arg.Res != nil {
if err := checkArg(arg.Res, typ1.Type); err != nil {
return err