diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_agent.c | 4 | ||||
-rw-r--r-- | channels/chan_dahdi.c | 11 | ||||
-rw-r--r-- | channels/chan_iax2.c | 3 | ||||
-rw-r--r-- | channels/chan_sip.c | 27 | ||||
-rw-r--r-- | channels/iax2-parser.c | 2 | ||||
-rw-r--r-- | channels/sip/reqresp_parser.c | 163 |
6 files changed, 57 insertions, 153 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 49f85635e..14447c754 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -668,7 +668,9 @@ static struct ast_frame *agent_read(struct ast_channel *ast) break; case AST_FRAME_DTMF_END: if (!p->acknowledged && (f->subclass.integer == p->acceptdtmf)) { - ast_verb(3, "%s acknowledged\n", ast_channel_name(p->chan)); + if (p->chan) { + ast_verb(3, "%s acknowledged\n", ast_channel_name(p->chan)); + } p->acknowledged = 1; ast_frfree(f); f = &answer_frame; diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 9a2352080..bead03a8a 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -8937,7 +8937,9 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast) ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel); /* If it's not us, return NULL immediately */ if (ast != p->owner) { - ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner)); + if (p->owner) { + ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner)); + } f = &p->subs[idx].f; return f; } @@ -11778,14 +11780,13 @@ static void *do_monitor(void *data) count = 0; for (i = iflist; i; i = i->next) { ast_mutex_lock(&i->lock); - if ((i->subs[SUB_REAL].dfd > -1) && i->sig && (!i->radio) && !(i->sig & SIG_MFCR2)) { + if (pfds && (i->subs[SUB_REAL].dfd > -1) && i->sig && (!i->radio) && !(i->sig & SIG_MFCR2)) { if (analog_lib_handles(i->sig, i->radio, i->oprmode)) { struct analog_pvt *p = i->sig_pvt; - if (!p) + if (!p) { ast_log(LOG_ERROR, "No sig_pvt?\n"); - - if (!p->owner && !p->subs[SUB_REAL].owner) { + } else if (!p->owner && !p->subs[SUB_REAL].owner) { /* This needs to be watched, as it lacks an owner */ pfds[count].fd = i->subs[SUB_REAL].dfd; pfds[count].events = POLLPRI; diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 8903041db..e3912175b 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -5285,7 +5285,7 @@ static int wait_for_peercallno(struct chan_iax2_pvt *pvt) DEADLOCK_AVOIDANCE(&iaxsl[callno]); pvt = iaxs[callno]; } - if (!pvt->peercallno) { + if (!pvt || !pvt->peercallno) { return -1; } } @@ -8669,6 +8669,7 @@ static void reg_source_db(struct iax2_peer *p) expiry = strrchr(data, ':'); if (!expiry) { ast_log(LOG_NOTICE, "IAX/Registry astdb entry missing expiry: '%s'\n", data); + return; } *expiry++ = '\0'; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index de2c80e55..29b92a51c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3188,7 +3188,7 @@ static int method_match(enum sipmethod id, const char *name) int len = strlen(sip_methods[id].text); int l_name = name ? strlen(name) : 0; /* true if the string is long enough, and ends with whitespace, and matches */ - return (l_name >= len && name[len] < 33 && + return (l_name >= len && name && name[len] < 33 && !strncasecmp(sip_methods[id].text, name, len)); } @@ -3492,7 +3492,7 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka } ast_debug(1, "Target address %s is not local, substituting externaddr\n", ast_sockaddr_stringify(them)); - } else if (p) { + } else { /* no remapping, but we bind to a specific address, so use it. */ switch (p->socket.type) { case SIP_TRANSPORT_TCP: @@ -3523,8 +3523,6 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka ast_sockaddr_set_port(us, ast_sockaddr_port(&bindaddr)); } } - } else if (!ast_sockaddr_is_any(&bindaddr)) { - ast_sockaddr_copy(us, &bindaddr); } ast_debug(3, "Setting SIP_TRANSPORT_%s with address %s\n", sip_get_transport(p->socket.type), ast_sockaddr_stringify(us)); } @@ -3667,7 +3665,7 @@ static int retrans_pkt(const void *data) pkt->retransid = -1; /* Kill this scheduler item */ - if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) { + if (pkt->method != SIP_OPTIONS && xmitres == 0) { if (pkt->is_fatal || sipdebug) { /* Tell us if it's critical or if we're debugging */ ast_log(LOG_WARNING, "Retransmission timeout reached on transmission %s for seqno %u (%s %s) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions\n" "Packet timed out after %dms with no response\n", @@ -7224,6 +7222,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit if (i->rtp) { ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0)); ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1)); + ast_rtp_instance_set_write_format(i->rtp, &fmt); + ast_rtp_instance_set_read_format(i->rtp, &fmt); } if (needvideo && i->vrtp) { ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0)); @@ -7243,11 +7243,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit ast_format_copy(ast_channel_writeformat(tmp), &fmt); ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt); - ast_rtp_instance_set_write_format(i->rtp, &fmt); ast_format_copy(ast_channel_readformat(tmp), &fmt); ast_format_copy(ast_channel_rawreadformat(tmp), &fmt); - ast_rtp_instance_set_read_format(i->rtp, &fmt); ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i")); @@ -8511,7 +8509,7 @@ static int sip_subscribe_mwi(const char *value, int lineno) int portnum = 0; enum sip_transport transport = SIP_TRANSPORT_UDP; char buf[256] = ""; - char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL, *at = NULL; + char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL; if (!value) { return -1; @@ -8519,13 +8517,12 @@ static int sip_subscribe_mwi(const char *value, int lineno) ast_copy_string(buf, value, sizeof(buf)); - if (!(at = strstr(buf, "@"))) { - return -1; - } + username = buf; if ((hostname = strrchr(buf, '@'))) { *hostname++ = '\0'; - username = buf; + } else { + return -1; } if ((secret = strchr(username, ':'))) { @@ -27283,8 +27280,12 @@ enum st_refresher st_get_refresher(struct sip_pvt *p) */ enum st_mode st_get_mode(struct sip_pvt *p, int no_cached) { - if (!p->stimer) + if (!p->stimer) { sip_st_alloc(p); + if (!p->stimer) { + return SESSION_TIMER_MODE_INVALID; + } + } if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID) return p->stimer->st_cached_mode; diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c index ce9af244d..7b12badf0 100644 --- a/channels/iax2-parser.c +++ b/channels/iax2-parser.c @@ -1192,7 +1192,7 @@ struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheab AST_LIST_TRAVERSE_SAFE_END; } if (!fr) { - if (iax_frames->size >= FRAME_CACHE_MAX_SIZE && smallest) { + if (iax_frames && iax_frames->size >= FRAME_CACHE_MAX_SIZE && smallest) { /* Make useless cache into something more useful */ AST_LIST_REMOVE(&iax_frames->list, smallest, list); if (!(fr = ast_realloc(smallest, sizeof(*fr) + datalen))) { diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c index b646f7bbb..e37d75b79 100644 --- a/channels/sip/reqresp_parser.c +++ b/channels/sip/reqresp_parser.c @@ -217,7 +217,7 @@ int parse_uri_full(char *uri, const char *scheme, char **user, char **pass, } -AST_TEST_DEFINE(sip_parse_uri_fully_test) +AST_TEST_DEFINE(sip_parse_uri_full_test) { int res = AST_TEST_PASS; char uri[1024]; @@ -227,12 +227,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata { char *desc; char *uri; - char **userptr; - char **passptr; - char **hostportptr; - char **headersptr; - char **residueptr; - struct uriparams *paramsptr; char *user; char *pass; char *hostport; @@ -250,12 +244,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td1 = { .desc = "no headers", .uri = "sip:user:secret@host:5060;param=discard;transport=tcp;param2=residue", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -269,12 +257,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td2 = { .desc = "with headers", .uri = "sip:user:secret@host:5060;param=discard;transport=tcp;param2=discard2?header=blah&header2=blah2;param3=residue", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -288,12 +270,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td3 = { .desc = "difficult user", .uri = "sip:-_.!~*'()&=+$,;?/:secret@host:5060;transport=tcp", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "-_.!~*'()&=+$,;?/", .pass = "secret", .hostport = "host:5060", @@ -307,12 +283,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td4 = { .desc = "difficult pass", .uri = "sip:user:-_.!~*'()&=+$,@host:5060;transport=tcp", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "-_.!~*'()&=+$,", .hostport = "host:5060", @@ -326,12 +296,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td5 = { .desc = "difficult host", .uri = "sip:user:secret@1-1.a-1.:5060;transport=tcp", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "1-1.a-1.:5060", @@ -345,12 +309,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td6 = { .desc = "difficult params near transport", .uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$;transport=tcp", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -364,12 +322,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td7 = { .desc = "difficult params near headers", .uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$?header=blah&header2=blah2;-_.!~*'()[]/:&+$=residue", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -383,12 +335,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td8 = { .desc = "lr parameter", .uri = "sip:user:secret@host:5060;param=discard;lr?header=blah", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -402,12 +348,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td9 = { .desc = "alternative lr parameter", .uri = "sip:user:secret@host:5060;param=discard;lr=yes?header=blah", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -421,12 +361,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) struct testdata td10 = { .desc = "no lr parameter", .uri = "sip:user:secret@host:5060;paramlr=lr;lr=no;lr=off;lr=0;lr=;=lr;lrextra;lrparam2=lr?header=blah", - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .user = "user", .pass = "secret", .hostport = "host:5060", @@ -469,19 +403,19 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test) params.lr = 0; ast_copy_string(uri,testdataptr->uri,sizeof(uri)); - if (parse_uri_full(uri, "sip:,sips:", testdataptr->userptr, - testdataptr->passptr, testdataptr->hostportptr, - testdataptr->paramsptr, - testdataptr->headersptr, - testdataptr->residueptr) || - ((testdataptr->userptr) && strcmp(testdataptr->user, user)) || - ((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) || - ((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) || - ((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) || - ((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) || - ((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) || - ((testdataptr->paramsptr) && (testdataptr->params.lr != params.lr)) || - ((testdataptr->paramsptr) && strcmp(testdataptr->params.user,params.user)) + if (parse_uri_full(uri, "sip:,sips:", &user, + &pass, &hostport, + ¶ms, + &headers, + &residue) || + (user && strcmp(testdataptr->user, user)) || + (pass && strcmp(testdataptr->pass, pass)) || + (hostport && strcmp(testdataptr->hostport, hostport)) || + (headers && strcmp(testdataptr->headers, headers)) || + (residue && strcmp(testdataptr->residue, residue)) || + (strcmp(testdataptr->params.transport,params.transport)) || + (testdataptr->params.lr != params.lr) || + (strcmp(testdataptr->params.user,params.user)) ) { ast_test_status_update(test, "Sub-Test: %s, failed.\n", testdataptr->desc); res = AST_TEST_FAIL; @@ -1220,13 +1154,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) struct testdata { char *desc; char *uri; - char **nameptr; - char **userptr; - char **passptr; - char **hostportptr; - char **headersptr; - char **residueptr; - struct uriparams *paramsptr; char *name; char *user; char *pass; @@ -1244,13 +1171,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) struct testdata td1 = { .desc = "quotes and brackets", .uri = "\"name :@ \" <sip:user:secret@host:5060;param=discard;transport=tcp>;tag=tag", - .nameptr = &name, - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .name = "name :@ ", .user = "user", .pass = "secret", @@ -1265,13 +1185,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) struct testdata td2 = { .desc = "no quotes", .uri = "givenname familyname <sip:user:secret@host:5060;param=discard;transport=tcp>;expires=3600", - .nameptr = &name, - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .name = "givenname familyname", .user = "user", .pass = "secret", @@ -1286,13 +1199,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) struct testdata td3 = { .desc = "no brackets", .uri = "sip:user:secret@host:5060;param=discard;transport=tcp;q=1", - .nameptr = &name, - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .name = "", .user = "user", .pass = "secret", @@ -1307,13 +1213,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) struct testdata td4 = { .desc = "just host", .uri = "sips:host", - .nameptr = &name, - .userptr = &user, - .passptr = &pass, - .hostportptr = &hostport, - .headersptr = &headers, - .residueptr = &residue, - .paramsptr = ¶ms, .name = "", .user = "", .pass = "", @@ -1351,21 +1250,21 @@ AST_TEST_DEFINE(parse_name_andor_addr_test) params.lr = 0; ast_copy_string(uri,testdataptr->uri,sizeof(uri)); if (parse_name_andor_addr(uri, "sip:,sips:", - testdataptr->nameptr, - testdataptr->userptr, - testdataptr->passptr, - testdataptr->hostportptr, - testdataptr->paramsptr, - testdataptr->headersptr, - testdataptr->residueptr) || - ((testdataptr->nameptr) && strcmp(testdataptr->name, name)) || - ((testdataptr->userptr) && strcmp(testdataptr->user, user)) || - ((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) || - ((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) || - ((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) || - ((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) || - ((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) || - ((testdataptr->paramsptr) && strcmp(testdataptr->params.user,params.user)) + &name, + &user, + &pass, + &hostport, + ¶ms, + &headers, + &residue) || + (name && strcmp(testdataptr->name, name)) || + (user && strcmp(testdataptr->user, user)) || + (pass && strcmp(testdataptr->pass, pass)) || + (hostport && strcmp(testdataptr->hostport, hostport)) || + (headers && strcmp(testdataptr->headers, headers)) || + (residue && strcmp(testdataptr->residue, residue)) || + (strcmp(testdataptr->params.transport,params.transport)) || + (strcmp(testdataptr->params.user,params.user)) ) { ast_test_status_update(test, "Sub-Test: %s,failed.\n", testdataptr->desc); res = AST_TEST_FAIL; @@ -2579,7 +2478,7 @@ void sip_request_parser_register_tests(void) AST_TEST_REGISTER(sip_parse_uri_test); AST_TEST_REGISTER(get_in_brackets_test); AST_TEST_REGISTER(get_name_and_number_test); - AST_TEST_REGISTER(sip_parse_uri_fully_test); + AST_TEST_REGISTER(sip_parse_uri_full_test); AST_TEST_REGISTER(parse_name_andor_addr_test); AST_TEST_REGISTER(parse_contact_header_test); AST_TEST_REGISTER(sip_parse_options_test); @@ -2592,7 +2491,7 @@ void sip_request_parser_unregister_tests(void) AST_TEST_UNREGISTER(get_calleridname_test); AST_TEST_UNREGISTER(get_in_brackets_test); AST_TEST_UNREGISTER(get_name_and_number_test); - AST_TEST_UNREGISTER(sip_parse_uri_fully_test); + AST_TEST_UNREGISTER(sip_parse_uri_full_test); AST_TEST_UNREGISTER(parse_name_andor_addr_test); AST_TEST_UNREGISTER(parse_contact_header_test); AST_TEST_UNREGISTER(sip_parse_options_test); |