[asterisk-commits] mmichelson: branch 11 r397254 - /branches/11/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 21 09:36:41 CDT 2013
Author: mmichelson
Date: Wed Aug 21 09:36:39 2013
New Revision: 397254
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397254
Log:
Prevent a crash on outbound SIP MESSAGE requests.
If a From header on an outbound out-of-call SIP MESSAGE were
malformed, the result could crash Asterisk.
In addition, if a From header on an incoming out-of-call SIP
MESSAGE request were malformed, the message was happily accepted
rather than being rejected up front. The incoming message path
would not result in a crash, but the behavior was bad nonetheless.
(closes issue ASTERISK-22185)
reported by Zhang Lei
Modified:
branches/11/channels/chan_sip.c
Modified: branches/11/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_sip.c?view=diff&rev=397254&r1=397253&r2=397254
==============================================================================
--- branches/11/channels/chan_sip.c (original)
+++ branches/11/channels/chan_sip.c Wed Aug 21 09:36:39 2013
@@ -18560,7 +18560,24 @@
ast_string_field_set(p, context, sip_cfg.messagecontext);
}
- get_destination(p, NULL, NULL);
+ switch (get_destination(p, NULL, NULL)) {
+ case SIP_GET_DEST_REFUSED:
+ /* Okay to send 403 since this is after auth processing */
+ transmit_response(p, "403 Forbidden", req);
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ return;
+ case SIP_GET_DEST_INVALID_URI:
+ transmit_response(p, "416 Unsupported URI Scheme", req);
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ return;
+ case SIP_GET_DEST_EXTEN_NOT_FOUND:
+ case SIP_GET_DEST_EXTEN_MATCHMORE:
+ transmit_response(p, "404 Not Found", req);
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ return;
+ case SIP_GET_DEST_EXTEN_FOUND:
+ break;
+ }
if (!(msg = ast_msg_alloc())) {
transmit_response(p, "500 Internal Server Error", req);
@@ -26832,6 +26849,21 @@
sender = ast_strdupa(from);
ast_callerid_parse(sender, &name, &location);
+ if (ast_strlen_zero(location)) {
+ /* This can occur if either
+ * 1) A name-addr style From header does not close the angle brackets
+ * properly.
+ * 2) The From header is not in name-addr style and the content of the
+ * From contains characters other than 0-9, *, #, or +.
+ *
+ * In both cases, ast_callerid_parse() should have parsed the From header
+ * as a name rather than a number. So we just need to set the location
+ * to what was parsed as a name, and set the name NULL since there was
+ * no name present.
+ */
+ location = name;
+ name = NULL;
+ }
ast_string_field_set(pvt, fromname, name);
if (strchr(location, ':')) { /* Must be a URI */
parse_uri(location, "sip:,sips:", &user, NULL, &domain, NULL);
More information about the asterisk-commits
mailing list