mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 03:59:43 +00:00
srtp: Improve the minimum encryption buffer size check
This clarifies where the limit number comes from, and only requires exactly as much padding space as will be needed. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
e1d0b3d875
commit
a2a991b2dd
@ -240,20 +240,24 @@ int ff_srtp_encrypt(struct SRTPContext *s, const uint8_t *in, int len,
|
|||||||
uint8_t iv[16] = { 0 }, hmac[20];
|
uint8_t iv[16] = { 0 }, hmac[20];
|
||||||
uint64_t index;
|
uint64_t index;
|
||||||
uint32_t ssrc;
|
uint32_t ssrc;
|
||||||
int rtcp, hmac_size;
|
int rtcp, hmac_size, padding;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
if (len + 14 > outlen)
|
|
||||||
return 0;
|
|
||||||
if (len < 12)
|
if (len < 12)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
rtcp = RTP_PT_IS_RTCP(in[1]);
|
||||||
|
hmac_size = rtcp ? s->rtcp_hmac_size : s->rtp_hmac_size;
|
||||||
|
padding = hmac_size;
|
||||||
|
if (rtcp)
|
||||||
|
padding += 4; // For the RTCP index
|
||||||
|
|
||||||
|
if (len + padding > outlen)
|
||||||
|
return 0;
|
||||||
|
|
||||||
memcpy(out, in, len);
|
memcpy(out, in, len);
|
||||||
buf = out;
|
buf = out;
|
||||||
|
|
||||||
rtcp = RTP_PT_IS_RTCP(buf[1]);
|
|
||||||
hmac_size = rtcp ? s->rtcp_hmac_size : s->rtp_hmac_size;
|
|
||||||
|
|
||||||
if (rtcp) {
|
if (rtcp) {
|
||||||
ssrc = AV_RB32(buf + 4);
|
ssrc = AV_RB32(buf + 4);
|
||||||
index = s->rtcp_index++;
|
index = s->rtcp_index++;
|
||||||
|
Loading…
Reference in New Issue
Block a user