Check slice length before access in a couple of more places (#4752)
* Check slice length before access in a couple of more places
* min 🤦
* lint
This commit is contained in:
@@ -154,7 +154,7 @@ func (b *Buffer) Write(pkt []byte) (n int, err error) {
|
|||||||
|
|
||||||
now := mono.UnixNano()
|
now := mono.UnixNano()
|
||||||
if b.twcc != nil && b.twccExtID != 0 {
|
if b.twcc != nil && b.twccExtID != 0 {
|
||||||
if ext := rtpPacket.GetExtension(b.twccExtID); ext != nil {
|
if ext := rtpPacket.GetExtension(b.twccExtID); len(ext) >= 2 {
|
||||||
b.twcc.Push(rtpPacket.SSRC, binary.BigEndian.Uint16(ext[0:2]), now, rtpPacket.Marker)
|
b.twcc.Push(rtpPacket.SSRC, binary.BigEndian.Uint16(ext[0:2]), now, rtpPacket.Marker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ func NewPlayoutDelayController(minDelay, maxDelay uint32, logger logger.Logger,
|
|||||||
rtpStats: rtpStats,
|
rtpStats: rtpStats,
|
||||||
senderSnapshotID: rtpStats.NewSenderSnapshotId(),
|
senderSnapshotID: rtpStats.NewSenderSnapshotId(),
|
||||||
}
|
}
|
||||||
return c, c.createExtData()
|
|
||||||
|
c.lock.Lock()
|
||||||
|
defer c.lock.Unlock()
|
||||||
|
return c, c.createExtDataLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PlayoutDelayController) GetState() PlayoutDelayControllerState {
|
func (c *PlayoutDelayController) GetState() PlayoutDelayControllerState {
|
||||||
@@ -157,8 +160,8 @@ func (c *PlayoutDelayController) SetJitter(jitter uint32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.currentDelay = targetDelay
|
c.currentDelay = targetDelay
|
||||||
|
c.createExtDataLocked()
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
c.createExtData()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PlayoutDelayController) OnSeqAcked(seq uint16) {
|
func (c *PlayoutDelayController) OnSeqAcked(seq uint16) {
|
||||||
@@ -186,7 +189,7 @@ func (c *PlayoutDelayController) GetDelayExtension(seq uint16) []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PlayoutDelayController) createExtData() error {
|
func (c *PlayoutDelayController) createExtDataLocked() error {
|
||||||
delay := pd.PlayoutDelayFromValue(
|
delay := pd.PlayoutDelayFromValue(
|
||||||
uint16(c.currentDelay),
|
uint16(c.currentDelay),
|
||||||
uint16(c.maxDelay),
|
uint16(c.maxDelay),
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func (r *RedPrimaryReceiver) ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int3
|
|||||||
"packetExtractedTS", pkts[i].Timestamp,
|
"packetExtractedTS", pkts[i].Timestamp,
|
||||||
"packetETS", pPkt.ExtTimestamp,
|
"packetETS", pPkt.ExtTimestamp,
|
||||||
"pktHistory", r.pktHistory,
|
"pktHistory", r.pktHistory,
|
||||||
"redHeader", pkt.Packet.Payload[:10],
|
"redHeader", pkt.Packet.Payload[:min(len(pkt.Packet.Payload), 10)],
|
||||||
"payloadSize", len(pkt.Packet.Payload),
|
"payloadSize", len(pkt.Packet.Payload),
|
||||||
"lastSeq", r.lastSeq,
|
"lastSeq", r.lastSeq,
|
||||||
"highestFowardedExtSequenceNumber", r.highestForwardedExtSequenceNumber,
|
"highestFowardedExtSequenceNumber", r.highestForwardedExtSequenceNumber,
|
||||||
|
|||||||
Reference in New Issue
Block a user