aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-trace2syz
diff options
context:
space:
mode:
authorShankara Pailoor <shankarapailoor@gmail.com>2019-01-08 08:17:41 -0800
committerDmitry Vyukov <dvyukov@google.com>2019-01-10 12:34:28 +0100
commitdb9b657915c1b95a5e768b249795b1aca278bb4e (patch)
treec30773d5c2dee250e7852eba234c1351f73ff1ff /tools/syz-trace2syz
parentf9ccea26eb0de391a874cfe56a414e573a81e9b2 (diff)
tools/syz-trace2syz/proggen/proggen_test.go: test ipv6 address conversion
Diffstat (limited to 'tools/syz-trace2syz')
-rw-r--r--tools/syz-trace2syz/proggen/proggen.go17
-rw-r--r--tools/syz-trace2syz/proggen/proggen_test.go18
2 files changed, 29 insertions, 6 deletions
diff --git a/tools/syz-trace2syz/proggen/proggen.go b/tools/syz-trace2syz/proggen/proggen.go
index 027befcef..c094edec1 100644
--- a/tools/syz-trace2syz/proggen/proggen.go
+++ b/tools/syz-trace2syz/proggen/proggen.go
@@ -339,19 +339,24 @@ func (ctx *context) genConst(syzType prog.Type, traceType parser.IrType) prog.Ar
// it is a good chance that we are decoding one of those fields. If it isn't, then most likely
// we have an error i.e. a sockaddr_un struct passed to a connect call with an inet file descriptor
var val uint64
+ toUint64 := binary.LittleEndian.Uint64
+ toUint32 := binary.LittleEndian.Uint32
+ toUint16 := binary.LittleEndian.Uint16
+ if syzType.Format() == prog.FormatBigEndian {
+ toUint64 = binary.BigEndian.Uint64
+ toUint32 = binary.BigEndian.Uint32
+ toUint16 = binary.BigEndian.Uint16
+ }
switch len(a.Val) {
case 8:
- val = uint64(binary.BigEndian.Uint64([]byte(a.Val)))
+ val = toUint64([]byte(a.Val))
case 4:
- // int
- val = uint64(binary.BigEndian.Uint32([]byte(a.Val)))
+ val = uint64(toUint32([]byte(a.Val)))
case 2:
- // short
- val = uint64(binary.BigEndian.Uint16([]byte(a.Val)))
+ val = uint64(toUint16([]byte(a.Val)))
case 1:
val = uint64(a.Val[0])
default:
- // The call almost certainly returned an errno
return syzType.DefaultArg()
}
return prog.MakeConstArg(syzType, val)
diff --git a/tools/syz-trace2syz/proggen/proggen_test.go b/tools/syz-trace2syz/proggen/proggen_test.go
index a0fd8520d..e572ec564 100644
--- a/tools/syz-trace2syz/proggen/proggen_test.go
+++ b/tools/syz-trace2syz/proggen/proggen_test.go
@@ -191,6 +191,24 @@ connect(3, {sa_family=0x2, sin_port="\x1f\x90", sin_addr="\x00"}, 16) = -1
r0 = socket$inet_tcp(0x2, 0x1, 0x0)
connect$inet(r0, &(0x7f0000000000)={0x2, 0x1f90}, 0x10)
`,
+ }, {`
+connect(-1, {sa_family=0xa, sin6_port="\x30\x39",` +
+ `sin6_addr="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01",` +
+ ` sin6_flowinfo="\x07\x5b\xcd\x7a", sin6_scope_id=4207869677}, 28) = -1
+`, `
+connect(0xffffffffffffffff, &(0x7f0000000000)=` +
+ `@in6={0xa, 0x3039, 0x75bcd7a, @rand_addr="00000000000000000000000000000001",` +
+ ` 0xfacefeed}, 0x80)
+`,
+ }, {`
+connect(-1, {sa_family=0xa, sin6_port="\x30\x39",` +
+ ` sin6_addr="\x00\x12\x00\x34\x00\x56\x00\x78\x00\x90\x00\xab\x00\xcd\x00\xef",` +
+ ` sin6_flowinfo="\x07\x5b\xcd\x7a", sin6_scope_id=4207869677}, 28) = -1
+`, `
+connect(0xffffffffffffffff, &(0x7f0000000000)=` +
+ `@in6={0xa, 0x3039, 0x75bcd7a, @rand_addr="0012003400560078009000ab00cd00ef",` +
+ ` 0xfacefeed}, 0x80)
+`,
},
}
target, err := prog.GetTarget("linux", "amd64")