-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix panic in avp.DecodeFromBytes #96
Conversation
in some cases method crashes with panic. Extra length check added. panic: runtime error: slice bounds out of range goroutine 27 [running]: github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185d40, 0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0x3, 0x800000c002686480) /go/src/github.com/fiorix/go-diameter/diam/avp.go:74 +0x5b1 github.com/fiorix/go-diameter/diam.DecodeAVP(0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0xc002686480, 0x8, 0x10) /go/src/github.com/fiorix/go-diameter/diam/avp.go:45 +0x74 github.com/fiorix/go-diameter/diam.DecodeGrouped(0xc002f861f0, 0xe0, 0x210, 0x4, 0xc0000a4050, 0xc000389400, 0x0, 0x0) /go/src/github.com/fiorix/go-diameter/diam/group.go:29 +0xfc github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185b00, 0xc002f861e4, 0xec, 0x21c, 0x4, 0xc0000
I'm surprised this check isn't elsewhere. Perhaps there's something else going on here. Where does 12 come from? Tests are failing, cannot proceed before tests pass. |
For what it's worth I have had this happen as well, interested to see what this would do |
panic occurs on line 71/74 avp.go I think data given to DecodeFromBytes method is not valid. |
* in some cases method crashes with panic. Extra length check added. not really sure, should it be 12 (payload = data[12:]) * Avp Length is already an int, no need for cast. panic: runtime error: slice bounds out of range goroutine 27 [running]: github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185d40, 0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0x3, 0x800000c002686480) /go/src/github.com/fiorix/go-diameter/diam/avp.go:74 +0x5b1 github.com/fiorix/go-diameter/diam.DecodeAVP(0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0xc002686480, 0x8, 0x10) /go/src/github.com/fiorix/go-diameter/diam/avp.go:45 +0x74 github.com/fiorix/go-diameter/diam.DecodeGrouped(0xc002f861f0, 0xe0, 0x210, 0x4, 0xc0000a4050, 0xc000389400, 0x0, 0x0) /go/src/github.com/fiorix/go-diameter/diam/group.go:29 +0xfc github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185b00, 0xc002f861e4, 0xec, 0x21c, 0x4, 0xc0000
Note that, in order to choose Go 1.10, you must use go: "1.10" (a string), not go: 1.10 (a float). Using a float results in the use of Go 1.1. - https://docs.travis-ci.com/user/languages/go/
541b376
to
cdebf4a
Compare
* Avp Length is already an int, no need for cast. * in some cases method crashes with panic. Extra length check added. not really sure, should it be 12 (payload = data[12:]) panic: runtime error: slice bounds out of range goroutine 27 [running]: github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185d40, 0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0x3, 0x800000c002686480) /go/src/github.com/fiorix/go-diameter/diam/avp.go:74 +0x5b1 github.com/fiorix/go-diameter/diam.DecodeAVP(0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0xc002686480, 0x8, 0x10) /go/src/github.com/fiorix/go-diameter/diam/avp.go:45 +0x74 github.com/fiorix/go-diameter/diam.DecodeGrouped(0xc002f861f0, 0xe0, 0x210, 0x4, 0xc0000a4050, 0xc000389400, 0x0, 0x0) /go/src/github.com/fiorix/go-diameter/diam/group.go:29 +0xfc github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185b00, 0xc002f861e4, 0xec, 0x21c, 0x4, 0xc0000
a2dd034
to
cb0c531
Compare
74be173
to
33fa2fe
Compare
simple channel receive instead of select with a single check TestHandleCER_VS_AuthSCTP was lower case
Good catch, thanks! |
in some cases method crashes with panic. Extra length check added.
panic: runtime error: slice bounds out of range
goroutine 27 [running]:
github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185d40, 0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0x3, 0x800000c002686480)
/go/src/github.com/fiorix/go-diameter/diam/avp.go:74 +0x5b1
github.com/fiorix/go-diameter/diam.DecodeAVP(0xc002f862a8, 0x28, 0x158, 0x4, 0xc0000a4050, 0xc002686480, 0x8, 0x10)
/go/src/github.com/fiorix/go-diameter/diam/avp.go:45 +0x74
github.com/fiorix/go-diameter/diam.DecodeGrouped(0xc002f861f0, 0xe0, 0x210, 0x4, 0xc0000a4050, 0xc000389400, 0x0, 0x0)
/go/src/github.com/fiorix/go-diameter/diam/group.go:29 +0xfc
github.com/fiorix/go-diameter/diam.(*AVP).DecodeFromBytes(0xc003185b00, 0xc002f861e4, 0xec, 0x21c, 0x4, 0xc0000