Skip to content

Commit 245c8ad

Browse files
committed
sdp: bound parsed SDP line count
Reported-by: Haruto Kimura (Stella) (cherry picked from commit 34d244171aa0aba7892c5567708cd4179aebb341)
1 parent 85da0c3 commit 245c8ad

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sdp_ops.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ int sdp_ops_parse_lines(struct sdp_body_part_ops *ops, str *body)
409409
if (*p != sep || (sep_len == 2 && p < (lim-1) && *(p+1) != '\n'))
410410
continue;
411411

412+
if (i >= SDP_MAX_LINES) {
413+
LM_ERR("SDP body exceeds maximum line count (%d)\n",
414+
SDP_MAX_LINES);
415+
return -1;
416+
}
417+
412418
/* lines are stored *without* the ending separator */
413419
ops->lines[i].line.s = start;
414420
ops->lines[i].line.len = p - start;
@@ -419,6 +425,12 @@ int sdp_ops_parse_lines(struct sdp_body_part_ops *ops, str *body)
419425

420426
/* edge-case: the very last SDP line does not include a separator... */
421427
if (start < lim) {
428+
if (i >= SDP_MAX_LINES) {
429+
LM_ERR("SDP body exceeds maximum line count (%d)\n",
430+
SDP_MAX_LINES);
431+
return -1;
432+
}
433+
422434
ops->lines[i].line.s = start;
423435
ops->lines[i].line.len = p - start;
424436
ops->lines[i++].newbuf = 0;

0 commit comments

Comments
 (0)