Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/sip/parse_cseq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "log.h"

#include <limits.h>

int parse_cseq(sip_cseq* cseq, const char* beg, int len)
{
enum {
Expand Down Expand Up @@ -65,6 +67,14 @@ int parse_cseq(sip_cseq* cseq, const char* beg, int len)
if(!IS_DIGIT(*c)){
return MALFORMED_SIP_MSG;
}
// reject overlarge CSeq numbers: the RFC 3261 CSeq value is a
// 32-bit quantity and 'num' is unsigned int; without this guard
// the accumulation silently wraps, so distinct on-wire CSeq
// strings can collapse to the same value and corrupt
// transaction matching.
if(cseq->num > (UINT_MAX - (unsigned int)(*c - '0')) / 10){
return MALFORMED_SIP_MSG;
}
cseq->num = cseq->num*10 + *c - '0';
Comment on lines +70 to 78
break;
}
Expand Down
Loading