修复webrtc转发可能内存越界的bug: #2159

This commit is contained in:
monktan89 2022-12-14 15:08:59 +08:00
parent 56ccd4332a
commit f6a36180b4

View File

@ -346,7 +346,7 @@ void WebRtcTransport::sendRtpPacket(const char *buf, int len, bool flush, void *
auto pkt = _packet_pool.obtain2();
// 预留rtx加入的两个字节
pkt->setCapacity((size_t)len + SRTP_MAX_TRAILER_LEN + 2);
pkt->assign(buf, len);
memcpy(pkt->data(), buf, len);
onBeforeEncryptRtp(pkt->data(), len, ctx);
if (_srtp_session_send->EncryptRtp(reinterpret_cast<uint8_t *>(pkt->data()), &len)) {
pkt->setSize(len);