Closed linpoyi closed 1 year ago
Tried to reproduce with this, but it successfully returned error, not crashing with slice bounds out of range. Can you check which version you're using?
package main
import (
"log"
"github.com/wmnsk/go-pfcp/message"
)
func main() {
b1 := []byte{0x20, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0xe8, 0x1f, 0xe7, 0xb4}
b2 := []byte{0x20, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x60, 0x00, 0x04, 0xe8, 0x1f, 0xdc, 0x30}
msg1, err := message.Parse(b1)
if err != nil {
log.Fatal(err)
}
msg2, err := message.Parse(b2)
if err != nil {
log.Fatal(err)
}
log.Printf("%v\n", msg1)
log.Printf("%v\n", msg2)
}
Hi @wmnsk , I was using v0.0.17-0.20221027122420-36112307f93a. So this problem is fixed in the latest version. After I updated to the latest version the error is gone, thanks for your help. BRs, Linpoyi
great, thank you for reporting 😃
hi @wmnsk It'll be safer to check if offset>offset+end before https://github.com/wmnsk/go-pfcp/blob/master/ie/ie.go#L557 also, check if i.MarshalLen()>len(b) before https://github.com/wmnsk/go-pfcp/blob/master/ie/ie.go#L500
we found "slice bounds out of range" error if
pfcp_heartbeat_request = b'\x20\x01\x00\x0c\x00\x00\x02\x00\x00\x60\x00\x00\xe8\x1f\xe7\xb4'
orpfcp_heartbeat_request = b'\x20\x01\x00\x0f\x00\x00\x00\xff\xff\xff\x00\x00\x60\x00\x04\xe8\x1f\xdc\x30'
BRs, Linpoyi