Azure / azure-event-hubs-go

Golang client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
89 stars 69 forks source link

Panic index out of range when receiving message from eventhub #250

Open buicongtan1997 opened 2 years ago

buicongtan1997 commented 2 years ago

I found this loc is not check len of msg.Data which causing panic: runtime error: index out of range [0] with length 0 when receiving message from eventhub https://github.com/Azure/azure-event-hubs-go/blob/73b7c0f7b25625f14c9a877ecb73230eba886107/event.go#L217

Expected Behavior

It can run properly

Actual Behavior

│ panic: runtime error: index out of range [0] with length 0
│ goroutine 105 [running]:
│ github.com/Azure/azure-event-hubs-go/v3.eventFromMsg(...)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/event.go:217
│ github.com/Azure/azure-event-hubs-go/v3.(*receiver).handleMessage(0xc0004b4000, 0x1815dd0, 0xc0000c4940, 0xc00063e2d0, 0xc0006b80a0)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:251 +0x75f
│ github.com/Azure/azure-event-hubs-go/v3.(*receiver).handleMessages(0xc0004b4000, 0x1815dd0, 0xc0000c4940, 0xc0002de900, 0xc0006b80a0)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:243 +0x106
│ created by github.com/Azure/azure-event-hubs-go/v3.(*receiver).Listen
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:227 +0x18c

Environment