Skip to content

Commit 4078510

Browse files
SAY-5matteius
authored andcommitted
fix(rtmp): prevent index out of range panic in encodeFLV
The bounds check hint asserted b[15] exists, but the buffer only needs to hold 15 bytes (4 prev-tag-size + 11 header) when the payload is empty. Lower the assertion to b[14] so an empty payload no longer panics. Closes AlexxIT#2061. Signed-off-by: SAY-5 <say.apm35@gmail.com>
1 parent eebfcb0 commit 4078510

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎pkg/rtmp/flv.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (c *Conn) Read(p []byte) (n int, err error) {
5555
}
5656

5757
func encodeFLV(b []byte, msgType byte, time uint32, payload []byte) {
58-
_ = b[4+11]
58+
_ = b[4+10] // bounds check hint to compiler; see golang.org/issue/14808
5959

6060
b[0] = 0
6161
b[1] = 0

0 commit comments

Comments
 (0)