[asterisk-commits] kpfleming: branch 1.4 r149452 - /branches/1.4/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 15 05:30:41 CDT 2008
Author: kpfleming
Date: Wed Oct 15 05:30:40 2008
New Revision: 149452
URL: http://svn.digium.com/view/asterisk?view=rev&rev=149452
Log:
fix some problems when parsing SIP messages that have the maximum number of headers or body lines that we support
Modified:
branches/1.4/channels/chan_sip.c
Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=149452&r1=149451&r2=149452
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Wed Oct 15 05:30:40 2008
@@ -4892,48 +4892,59 @@
}
if (f >= SIP_MAX_HEADERS - 1) {
ast_log(LOG_WARNING, "Too many SIP headers. Ignoring.\n");
- } else
+ } else {
f++;
- req->header[f] = c + 1;
+ req->header[f] = c + 1;
+ }
} else if (*c == '\r') {
/* Ignore but eliminate \r's */
*c = 0;
}
c++;
}
- /* Check for last header */
+
+ req->headers = f;
+
+ /* Check a non-newline-terminated last header */
if (!ast_strlen_zero(req->header[f])) {
if (sipdebug && option_debug > 3)
ast_log(LOG_DEBUG, "Header %d: %s (%d)\n", f, req->header[f], (int) strlen(req->header[f]));
- f++;
- }
- req->headers = f;
- /* Now we process any mime content */
+ req->headers++;
+ }
+
+ /* Now we process any body content */
f = 0;
req->line[f] = c;
- while(*c) {
+ while (*c) {
if (*c == '\n') {
/* We've got a new line */
*c = 0;
if (sipdebug && option_debug > 3)
ast_log(LOG_DEBUG, "Line: %s (%d)\n", req->line[f], (int) strlen(req->line[f]));
- if (f >= SIP_MAX_LINES - 1) {
+ if (f == SIP_MAX_LINES - 1) {
ast_log(LOG_WARNING, "Too many SDP lines. Ignoring.\n");
- } else
+ break;
+ } else {
f++;
- req->line[f] = c + 1;
+ req->line[f] = c + 1;
+ }
} else if (*c == '\r') {
/* Ignore and eliminate \r's */
*c = 0;
}
c++;
}
- /* Check for last line */
- if (!ast_strlen_zero(req->line[f]))
- f++;
+
req->lines = f;
+
+ /* Check a non-newline-terminated last line */
+ if (!ast_strlen_zero(req->line[f])) {
+ req->lines++;
+ }
+
if (*c)
ast_log(LOG_WARNING, "Odd content, extra stuff left over ('%s')\n", c);
+
/* Split up the first line parts */
return determine_firstline_parts(req);
}
More information about the asterisk-commits
mailing list