Added panic on small buffer for Ping.Marshal.
This commit is contained in:
@@ -37,6 +37,8 @@ type Ping struct {
|
||||
// buf[:Size]. Taking the buffer lets callers reuse one across sends; every
|
||||
// field is written unconditionally so a reused buffer needs no pre-zeroing.
|
||||
func (p Ping) Marshal(buf []byte) []byte {
|
||||
_ = buf[Size-1] // Panic if buffer is too small.
|
||||
|
||||
buf[0] = version
|
||||
binary.BigEndian.PutUint64(buf[1:9], uint64(p.PingTS))
|
||||
if p.SrcV4.IsValid() {
|
||||
|
||||
Reference in New Issue
Block a user