X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libs%2Fsrtp%2Fsrtp.c;h=c9414374a42b63db0a3b605a74fbc02657372355;hb=5c09dbbad9c76ea76d7060b0fee10b7d3c8abb3a;hp=f60147bfa6c0dcdabda9b5ea160787ff83168c82;hpb=54a4638723464f86744b43be273474367a131891;p=vlc diff --git a/libs/srtp/srtp.c b/libs/srtp/srtp.c index f60147bfa6..c9414374a4 100644 --- a/libs/srtp/srtp.c +++ b/libs/srtp/srtp.c @@ -651,6 +651,7 @@ srtcp_send (srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t bufsize) const uint8_t *tag = rtcp_digest (s->rtp.mac, buf, len); memcpy (buf + len, tag, s->tag_len); *lenp = len + s->tag_len; + s->rtcp_index++; /* Update index */ return 0; } @@ -682,8 +683,13 @@ srtcp_recv (srtp_session_t *s, uint8_t *buf, size_t *lenp) return EACCES; len -= 4; /* Remove SRTCP index before decryption */ - *lenp = len; + uint32_t index; + memcpy (&index, buf + len, 4); + index = ntohl (index); + if (((index - s->rtcp_index) & 0xffffffff) < 0x80000000) + s->rtcp_index = index; /* Update index */ + *lenp = len; return srtp_crypt (s, buf, len); }