From 467e368cc1c6b50ed8ed3c517606ad59c4211f6c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 22 Oct 2014 21:08:34 +0100 Subject: [PATCH] check for overflowing msg len when unpacking A unclebadtouches catched this. closes #141 --- msg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msg.go b/msg.go index 2b12cd48..6ed21a07 100644 --- a/msg.go +++ b/msg.go @@ -1005,7 +1005,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er if off == lenmsg { break // dyn. update } - if off+net.IPv4len > rdend { + if off+net.IPv4len > rdend || off+net.IPv4len > lenmsg { return lenmsg, &Error{err: "overflow unpacking a"} } fv.Set(reflect.ValueOf(net.IPv4(msg[off], msg[off+1], msg[off+2], msg[off+3])))