nsqio / go-nsq

The official Go package for NSQ
MIT License
2.59k stars 444 forks source link

nsqd: check response message size is positive #267

Closed andyxning closed 5 years ago

andyxning commented 5 years ago

This PR adds pre check for msg size before make a slice.

We have encountered a panic in make([]byte, msgSize) with panic: runtime error: makeslice: len out of range. We have bounded the max message size by 20MB. So, it seems that make function should not panic.

I have test that when make with a negative length, make will panic with panic: runtime error: makeslice: len out of range.

ploxiln commented 5 years ago

This change looks obviously correct.

I think the commit title could be more specific - this is for reading a response message. Perhaps "check response message size is positive"