Check that chunk buffer length fits in 16 bit.

Change-Id: Id086a54aa8a1990c1979e747c1c02e53bed6d447
This commit is contained in:
Julius Volz 2014-08-20 15:05:04 +02:00 committed by Bjoern Rabenstein
parent 1ca7f24137
commit fd01d07589
1 changed files with 3 additions and 1 deletions

View File

@ -326,7 +326,9 @@ func (c *deltaEncodedChunk) lastTime() clientmodel.Timestamp {
}
func (c *deltaEncodedChunk) marshal(w io.Writer) error {
// TODO: check somewhere that configured buf len cannot overflow 16 bit.
if len(c.buf) > math.MaxUint16 {
panic("chunk buffer length would overflow a 16 bit uint.")
}
binary.LittleEndian.PutUint16(c.buf[deltaHeaderBufLenOffset:], uint16(len(c.buf)))
n, err := w.Write(c.buf[:cap(c.buf)])