Skip to content

Commit

Permalink
SRTP: check buffer length before sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Jun 15, 2008
1 parent 74e39ff commit bc3af7e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libs/srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,21 @@ int
srtp_send (srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t bufsize)
{
size_t len = *lenp;
int val = srtp_crypt (s, buf, len);
if (val)
return val;
size_t tag_len = s->tag_len;

if (!(s->flags & SRTP_UNAUTHENTICATED))
{
size_t tag_len = s->tag_len;
*lenp = len + tag_len;
if (bufsize < (len + tag_len))
return ENOSPC;
}

int val = srtp_crypt (s, buf, len);
if (val)
return val;

if (!(s->flags & SRTP_UNAUTHENTICATED))
{
uint32_t roc = srtp_compute_roc (s, rtp_seq (buf));
const uint8_t *tag = rtp_digest (s, buf, len, roc);
if (rcc_mode (s))
Expand Down

0 comments on commit bc3af7e

Please sign in to comment.