[asterisk-commits] kmoore: branch 1.8 r366167 - in /branches/1.8: apps/ channels/ channels/sip/ ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 10 15:50:54 CDT 2012
Author: kmoore
Date: Thu May 10 15:50:47 2012
New Revision: 366167
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366167
Log:
Resolve FORWARD_NULL static analysis warnings
This resolves core findings from ASTERISK-19650 numbers 0-2, 6, 7, 9-11, 14-20,
22-24, 28, 30-32, 34-36, 42-56, 82-84, 87, 89-90, 93-102, 104, 105, 109-111,
and 115. Finding numbers 26, 33, and 29 were already resolved. Those skipped
were either extended/deprecated or in areas of code that shouldn't be
disturbed.
(Closes issue ASTERISK-19650)
Modified:
branches/1.8/apps/app_voicemail.c
branches/1.8/channels/chan_agent.c
branches/1.8/channels/chan_dahdi.c
branches/1.8/channels/chan_iax2.c
branches/1.8/channels/chan_sip.c
branches/1.8/channels/iax2-parser.c
branches/1.8/channels/sip/reqresp_parser.c
branches/1.8/funcs/func_lock.c
branches/1.8/funcs/func_speex.c
branches/1.8/main/app.c
branches/1.8/main/cdr.c
branches/1.8/main/channel.c
branches/1.8/main/config.c
branches/1.8/main/data.c
branches/1.8/main/devicestate.c
branches/1.8/main/event.c
branches/1.8/main/features.c
branches/1.8/main/manager.c
branches/1.8/main/pbx.c
branches/1.8/main/tcptls.c
branches/1.8/main/xmldoc.c
branches/1.8/pbx/dundi-parser.c
branches/1.8/pbx/pbx_dundi.c
branches/1.8/res/ael/pval.c
branches/1.8/res/res_calendar_icalendar.c
branches/1.8/res/res_monitor.c
branches/1.8/res/res_odbc.c
Modified: branches/1.8/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_voicemail.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/apps/app_voicemail.c (original)
+++ branches/1.8/apps/app_voicemail.c Thu May 10 15:50:47 2012
@@ -11170,13 +11170,15 @@
AST_LIST_UNLOCK(&users);
return CLI_FAILURE;
}
- if (a->argc == 3)
+ if (!context) {
ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
- else {
+ } else {
int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) {
- if (!strcmp(context, vmu->context))
+ if (!strcmp(context, vmu->context)) {
count++;
+ break;
+ }
}
if (count) {
ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
@@ -11190,7 +11192,7 @@
int newmsgs = 0, oldmsgs = 0;
char count[12], tmp[256] = "";
- if ((a->argc == 3) || ((a->argc == 5) && !strcmp(context, vmu->context))) {
+ if (!context || !strcmp(context, vmu->context)) {
snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count, sizeof(count), "%d", newmsgs);
Modified: branches/1.8/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_agent.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/chan_agent.c (original)
+++ branches/1.8/channels/chan_agent.c Thu May 10 15:50:47 2012
@@ -668,7 +668,9 @@
break;
case AST_FRAME_DTMF_END:
if (!p->acknowledged && (f->subclass.integer == p->acceptdtmf)) {
- ast_verb(3, "%s acknowledged\n", p->chan->name);
+ if (p->chan) {
+ ast_verb(3, "%s acknowledged\n", p->chan->name);
+ }
p->acknowledged = 1;
ast_frfree(f);
f = &answer_frame;
Modified: branches/1.8/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_dahdi.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/chan_dahdi.c (original)
+++ branches/1.8/channels/chan_dahdi.c Thu May 10 15:50:47 2012
@@ -8852,7 +8852,9 @@
ast_debug(1, "Exception on %d, channel %d\n", ast->fds[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->name, p->owner->name);
+ if (p->owner) {
+ ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
+ }
f = &p->subs[idx].f;
return f;
}
@@ -11673,14 +11675,13 @@
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;
Modified: branches/1.8/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_iax2.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/chan_iax2.c (original)
+++ branches/1.8/channels/chan_iax2.c Thu May 10 15:50:47 2012
@@ -5279,7 +5279,7 @@
DEADLOCK_AVOIDANCE(&iaxsl[callno]);
pvt = iaxs[callno];
}
- if (!pvt->peercallno) {
+ if (!pvt || !pvt->peercallno) {
return -1;
}
}
@@ -8663,6 +8663,7 @@
expiry = strrchr(data, ':');
if (!expiry) {
ast_log(LOG_NOTICE, "IAX/Registry astdb entry missing expiry: '%s'\n", data);
+ return;
}
*expiry++ = '\0';
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Thu May 10 15:50:47 2012
@@ -3157,7 +3157,7 @@
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));
}
@@ -3461,7 +3461,7 @@
}
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:
@@ -3492,8 +3492,6 @@
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", get_transport(p->socket.type), ast_sockaddr_stringify(us));
}
@@ -3636,7 +3634,7 @@
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",
@@ -7126,6 +7124,8 @@
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));
@@ -7144,11 +7144,9 @@
tmp->writeformat = fmt;
tmp->rawwriteformat = fmt;
- ast_rtp_instance_set_write_format(i->rtp, fmt);
tmp->readformat = fmt;
tmp->rawreadformat = fmt;
- ast_rtp_instance_set_read_format(i->rtp, fmt);
tmp->tech_pvt = dialog_ref(i, "sip_new: set chan->tech_pvt to i");
@@ -8254,7 +8252,7 @@
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;
@@ -8262,13 +8260,12 @@
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, ':'))) {
@@ -26208,8 +26205,12 @@
*/
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;
Modified: branches/1.8/channels/iax2-parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/iax2-parser.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/iax2-parser.c (original)
+++ branches/1.8/channels/iax2-parser.c Thu May 10 15:50:47 2012
@@ -1192,7 +1192,7 @@
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))) {
Modified: branches/1.8/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sip/reqresp_parser.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/channels/sip/reqresp_parser.c (original)
+++ branches/1.8/channels/sip/reqresp_parser.c Thu May 10 15:50:47 2012
@@ -217,7 +217,7 @@
}
-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 @@
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 @@
struct testdata td1 = {
.desc = "no headers",
.uri = "sip:user:secret at 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 @@
struct testdata td2 = {
.desc = "with headers",
.uri = "sip:user:secret at 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 @@
struct testdata td3 = {
.desc = "difficult user",
.uri = "sip:-_.!~*'()&=+$,;?/:secret at 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 @@
struct testdata td4 = {
.desc = "difficult pass",
.uri = "sip:user:-_.!~*'()&=+$, at 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 @@
struct testdata td5 = {
.desc = "difficult host",
.uri = "sip:user:secret at 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 @@
struct testdata td6 = {
.desc = "difficult params near transport",
.uri = "sip:user:secret at 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 @@
struct testdata td7 = {
.desc = "difficult params near headers",
.uri = "sip:user:secret at 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 @@
struct testdata td8 = {
.desc = "lr parameter",
.uri = "sip:user:secret at 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 @@
struct testdata td9 = {
.desc = "alternative lr parameter",
.uri = "sip:user:secret at 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 @@
struct testdata td10 = {
.desc = "no lr parameter",
.uri = "sip:user:secret at 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 @@
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 @@
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 @@
struct testdata td1 = {
.desc = "quotes and brackets",
.uri = "\"name :@ \" <sip:user:secret at 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 @@
struct testdata td2 = {
.desc = "no quotes",
.uri = "givenname familyname <sip:user:secret at 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 @@
struct testdata td3 = {
.desc = "no brackets",
.uri = "sip:user:secret at 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 @@
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 @@
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 @@
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 @@
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);
Modified: branches/1.8/funcs/func_lock.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_lock.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/funcs/func_lock.c (original)
+++ branches/1.8/funcs/func_lock.c Thu May 10 15:50:47 2012
@@ -373,10 +373,15 @@
static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- struct ast_datastore *lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
+ struct ast_datastore *lock_store;
struct channel_lock_frame *clframe;
AST_LIST_HEAD(, channel_lock_frame) *list;
+ if (!chan) {
+ return -1;
+ }
+
+ lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
if (!lock_store) {
ast_log(LOG_WARNING, "No datastore for dialplan locks. Nothing was ever locked!\n");
ast_copy_string(buf, "0", len);
@@ -417,26 +422,24 @@
static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- if (chan)
- ast_autoservice_start(chan);
-
+ if (!chan) {
+ return -1;
+ }
+ ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 0) ? "0" : "1", len);
-
- if (chan)
- ast_autoservice_stop(chan);
+ ast_autoservice_stop(chan);
return 0;
}
static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- if (chan)
- ast_autoservice_start(chan);
-
+ if (!chan) {
+ return -1;
+ }
+ ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 1) ? "0" : "1", len);
-
- if (chan)
- ast_autoservice_stop(chan);
+ ast_autoservice_stop(chan);
return 0;
}
Modified: branches/1.8/funcs/func_speex.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_speex.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/funcs/func_speex.c (original)
+++ branches/1.8/funcs/func_speex.c Thu May 10 15:50:47 2012
@@ -200,6 +200,11 @@
struct speex_direction_info **sdi = NULL;
int is_new = 0;
+ if (strcasecmp(data, "rx") && strcasecmp(data, "tx")) {
+ ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
+ return -1;
+ }
+
ast_channel_lock(chan);
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
ast_channel_unlock(chan);
@@ -224,15 +229,8 @@
if (!strcasecmp(data, "rx")) {
sdi = &si->rx;
- } else if (!strcasecmp(data, "tx")) {
+ } else {
sdi = &si->tx;
- } else {
- ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
-
- if (is_new) {
- ast_datastore_free(datastore);
- return -1;
- }
}
if (!*sdi) {
Modified: branches/1.8/main/app.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/app.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/app.c (original)
+++ branches/1.8/main/app.c Thu May 10 15:50:47 2012
@@ -570,6 +570,9 @@
long pause_restart_point = 0;
long offset = 0;
+ if (!file) {
+ return -1;
+ }
if (offsetms) {
offset = *offsetms * 8; /* XXX Assumes 8kHz */
}
@@ -601,12 +604,10 @@
res = ast_answer(chan);
}
- if (file) {
- if ((end = strchr(file, ':'))) {
- if (!strcasecmp(end, ":end")) {
- *end = '\0';
- end++;
- }
+ if ((end = strchr(file, ':'))) {
+ if (!strcasecmp(end, ":end")) {
+ *end = '\0';
+ end++;
}
}
Modified: branches/1.8/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/cdr.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/cdr.c (original)
+++ branches/1.8/main/cdr.c Thu May 10 15:50:47 2012
@@ -573,7 +573,9 @@
lfrom = lfrom->next;
}
/* rip off the last entry and put a copy of the to at the end */
- llfrom->next = to;
+ if (llfrom) {
+ llfrom->next = to;
+ }
from = lfrom;
} else {
/* save copy of the current *to cdr */
@@ -589,10 +591,11 @@
}
from->next = NULL;
/* rip off the last entry and put a copy of the to at the end */
- if (llfrom == from)
+ if (llfrom == from) {
to = to->next = ast_cdr_dup(&tcdr);
- else
+ } else if (llfrom) {
to = llfrom->next = ast_cdr_dup(&tcdr);
+ }
from = lfrom;
}
}
Modified: branches/1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/channel.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/channel.c (original)
+++ branches/1.8/main/channel.c Thu May 10 15:50:47 2012
@@ -3132,16 +3132,19 @@
int fdno;
} *fdmap = NULL;
- if ((sz = n * AST_MAX_FDS + nfds)) {
- pfds = alloca(sizeof(*pfds) * sz);
- fdmap = alloca(sizeof(*fdmap) * sz);
- }
-
if (outfd)
*outfd = -99999;
if (exception)
*exception = 0;
+ if ((sz = n * AST_MAX_FDS + nfds)) {
+ pfds = alloca(sizeof(*pfds) * sz);
+ fdmap = alloca(sizeof(*fdmap) * sz);
+ } else {
+ /* nothing to allocate and no FDs to check */
+ return NULL;
+ }
+
/* Perform any pending masquerades */
for (x = 0; x < n; x++) {
if (c[x]->masq && ast_do_masquerade(c[x])) {
Modified: branches/1.8/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/config.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/config.c (original)
+++ branches/1.8/main/config.c Thu May 10 15:50:47 2012
@@ -562,7 +562,11 @@
{
struct ast_category *cat = NULL;
- if (category && config->last_browse && (config->last_browse->name == category)) {
+ if (!category) {
+ return NULL;
+ }
+
+ if (config->last_browse && (config->last_browse->name == category)) {
cat = config->last_browse;
} else {
cat = ast_category_get(config, category);
@@ -1896,7 +1900,7 @@
/* Dump section with any appropriate comment */
for (cmt = cat->precomments; cmt; cmt=cmt->next) {
char *cmtp = cmt->cmt;
- while (*cmtp == ';' && *(cmtp+1) == '!') {
+ while (cmtp && *cmtp == ';' && *(cmtp+1) == '!') {
char *cmtp2 = strchr(cmtp+1, '\n');
if (cmtp2)
cmtp = cmtp2+1;
Modified: branches/1.8/main/data.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/data.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/data.c (original)
+++ branches/1.8/main/data.c Thu May 10 15:50:47 2012
@@ -2496,18 +2496,20 @@
struct ast_data *internal = tree;
char *path, *ptr = NULL;
+ if (!elements) {
+ return NULL;
+ }
+
/* tree is the node we want to use to iterate? or we are going
* to iterate thow an internal node? */
- if (elements) {
- path = ast_strdupa(elements);
-
- ptr = strrchr(path, '/');
- if (ptr) {
- *ptr = '\0';
- internal = data_result_get_node(tree, path);
- if (!internal) {
- return NULL;
- }
+ path = ast_strdupa(elements);
+
+ ptr = strrchr(path, '/');
+ if (ptr) {
+ *ptr = '\0';
+ internal = data_result_get_node(tree, path);
+ if (!internal) {
+ return NULL;
}
}
Modified: branches/1.8/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/devicestate.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/devicestate.c (original)
+++ branches/1.8/main/devicestate.c Thu May 10 15:50:47 2012
@@ -330,9 +330,7 @@
/* We have a provider */
number = tech;
tech = NULL;
- }
-
- if (provider) {
+
ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
return getproviderstate(provider, number);
}
Modified: branches/1.8/main/event.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/event.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/event.c (original)
+++ branches/1.8/main/event.c Thu May 10 15:50:47 2012
@@ -1281,8 +1281,9 @@
break;
}
+ /* realloc inside one of the append functions failed */
if (!event) {
- break;
+ return NULL;
}
}
Modified: branches/1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/features.c?view=diff&rev=366167&r1=366166&r2=366167
==============================================================================
--- branches/1.8/main/features.c (original)
+++ branches/1.8/main/features.c Thu May 10 15:50:47 2012
@@ -2060,6 +2060,9 @@
struct ast_channel *caller_chan, *callee_chan;
const char *automon_message_start = NULL;
const char *automon_message_stop = NULL;
+ const char *touch_format = NULL;
+ const char *touch_monitor = NULL;
+ const char *touch_monitor_prefix = NULL;
if (!monitor_ok) {
ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
@@ -2073,10 +2076,13 @@
}
set_peers(&caller_chan, &callee_chan, peer, chan, sense);
- if (caller_chan) { /* Find extra messages */
- automon_message_start = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_START");
- automon_message_stop = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_STOP");
- }
+ if (!caller_chan || !callee_chan) {
+ ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
+ return -1;
+ }
+ /* Find extra messages */
+ automon_message_start = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_START");
+ automon_message_stop = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_STOP");
if (!ast_strlen_zero(courtesytone)) { /* Play courtesy tone if configured */
if(play_message_in_bridged_call(caller_chan, callee_chan, courtesytone) == -1) {
@@ -2093,58 +2099,53 @@
return AST_FEATURE_RETURN_SUCCESS;
}
- if (caller_chan && callee_chan) {
- const char *touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT");
- const char *touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR");
- const char *touch_monitor_prefix = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_PREFIX");
-
- if (!touch_format)
- touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT");
-
- if (!touch_monitor)
- touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR");
+ touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT");
+ touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR");
+ touch_monitor_prefix = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_PREFIX");
+
+ if (!touch_format)
+ touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT");
+
+ if (!touch_monitor)
+ touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR");
+
+ if (!touch_monitor_prefix)
+ touch_monitor_prefix = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_PREFIX");
+
+ if (touch_monitor) {
+ len = strlen(touch_monitor) + 50;
+ args = alloca(len);
+ touch_filename = alloca(len);
+ snprintf(touch_filename, len, "%s-%ld-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), touch_monitor);
+ snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
+ } else {
+ caller_chan_id = ast_strdupa(S_COR(caller_chan->caller.id.number.valid,
+ caller_chan->caller.id.number.str, caller_chan->name));
+ callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
+ callee_chan->caller.id.number.str, callee_chan->name));
+ len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
+ args = alloca(len);
+ touch_filename = alloca(len);
+ snprintf(touch_filename, len, "%s-%ld-%s-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), caller_chan_id, callee_chan_id);
+ snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
+ }
+
+ for(x = 0; x < strlen(args); x++) {
+ if (args[x] == '/')
+ args[x] = '-';
+ }
- if (!touch_monitor_prefix)
- touch_monitor_prefix = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_PREFIX");
-
- if (touch_monitor) {
- len = strlen(touch_monitor) + 50;
- args = alloca(len);
- touch_filename = alloca(len);
- snprintf(touch_filename, len, "%s-%ld-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), touch_monitor);
- snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
- } else {
- caller_chan_id = ast_strdupa(S_COR(caller_chan->caller.id.number.valid,
- caller_chan->caller.id.number.str, caller_chan->name));
- callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
- callee_chan->caller.id.number.str, callee_chan->name));
- len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
- args = alloca(len);
- touch_filename = alloca(len);
- snprintf(touch_filename, len, "%s-%ld-%s-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), caller_chan_id, callee_chan_id);
- snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
- }
-
- for(x = 0; x < strlen(args); x++) {
- if (args[x] == '/')
- args[x] = '-';
- }
-
- ast_verb(4, "User hit '%s' to record call. filename: %s\n", code, args);
-
- pbx_exec(callee_chan, monitor_app, args);
- pbx_builtin_setvar_helper(callee_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
- pbx_builtin_setvar_helper(caller_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
-
- if (!ast_strlen_zero(automon_message_start)) { /* Play start message for both channels */
- play_message_in_bridged_call(caller_chan, callee_chan, automon_message_start);
- }
-
- return AST_FEATURE_RETURN_SUCCESS;
- }
-
- ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
- return -1;
+ ast_verb(4, "User hit '%s' to record call. filename: %s\n", code, args);
+
+ pbx_exec(callee_chan, monitor_app, args);
+ pbx_builtin_setvar_helper(callee_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
+ pbx_builtin_setvar_helper(caller_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
+
+ if (!ast_strlen_zero(automon_message_start)) { /* Play start message for both channels */
+ play_message_in_bridged_call(caller_chan, callee_chan, automon_message_start);
+ }
+
+ return AST_FEATURE_RETURN_SUCCESS;
}
static int builtin_automixmonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data)
@@ -3164,12 +3165,10 @@
ast_autoservice_start(idle);
ast_autoservice_ignore(idle, AST_FRAME_DTMF_END);
- if(work && idle) {
- pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", idle->name);
- pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", work->name);
- pbx_builtin_setvar_helper(work, "DYNAMIC_FEATURENAME", feature->sname);
- pbx_builtin_setvar_helper(idle, "DYNAMIC_FEATURENAME", feature->sname);
- }
+ pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", idle->name);
+ pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", work->name);
+ pbx_builtin_setvar_helper(work, "DYNAMIC_FEATURENAME", feature->sname);
+ pbx_builtin_setvar_helper(idle, "DYNAMIC_FEATURENAME", feature->sname);
if (!ast_strlen_zero(feature->moh_class))
ast_moh_start(idle, feature->moh_class, NULL);
@@ -3284,7 +3283,9 @@
if (operation) {
res = fge->feature->operation(chan, peer, config, code, sense, fge->feature);
}
- memcpy(feature, fge->feature, sizeof(*feature));
+ if (feature) {
+ memcpy(feature, fge->feature, sizeof(*feature));
+ }
if (res != AST_FEATURE_RETURN_KEEPTRYING) {
AST_RWLIST_UNLOCK(&feature_groups);
break;
@@ -4730,76 +4731,80 @@
/* And take them out of the parking lot */
parking_complete = 1;
} else { /* still within parking time, process descriptors */
- for (x = 0; x < AST_MAX_FDS; x++) {
- struct ast_frame *f;
- int y;
-
- if (chan->fds[x] == -1) {
- continue; /* nothing on this descriptor */
- }
-
- for (y = 0; y < nfds; y++) {
- if (pfds[y].fd == chan->fds[x]) {
- /* Found poll record! */
+ x = 0;
+ if (pfds) {
+ for (; x < AST_MAX_FDS; x++) {
+ struct ast_frame *f;
+ int y;
+
+ if (chan->fds[x] == -1) {
+ continue; /* nothing on this descriptor */
+ }
+
+ for (y = 0; y < nfds; y++) {
+ if (pfds[y].fd == chan->fds[x]) {
+ /* Found poll record! */
+ break;
+ }
+ }
+ if (y == nfds) {
+ /* Not found */
+ continue;
+ }
+
+ if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
+ /* Next x */
+ continue;
+ }
+
+ if (pfds[y].revents & POLLPRI) {
+ ast_set_flag(chan, AST_FLAG_EXCEPTION);
+ } else {
+ ast_clear_flag(chan, AST_FLAG_EXCEPTION);
+ }
+ chan->fdno = x;
+
+ /* See if they need servicing */
+ f = ast_read(pu->chan);
+ /* Hangup? */
+ if (!f || (f->frametype == AST_FRAME_CONTROL
+ && f->subclass.integer == AST_CONTROL_HANGUP)) {
+ if (f) {
+ ast_frfree(f);
+ }
+ post_manager_event("ParkedCallGiveUp", pu);
+ ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp",
+ NULL);
+
+ /* There's a problem, hang them up */
+ ast_verb(2, "%s got tired of being parked\n", chan->name);
+ ast_hangup(chan);
+
+ /* And take them out of the parking lot */
+ parking_complete = 1;
break;
+ } else {
+ /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
+ ast_frfree(f);
+ if (pu->hold_method == AST_CONTROL_HOLD
+ && pu->moh_trys < 3
+ && !chan->generatordata) {
+ ast_debug(1,
+ "MOH on parked call stopped by outside source. Restarting on channel %s.\n",
+ chan->name);
+ ast_indicate_data(chan, AST_CONTROL_HOLD,
+ S_OR(pu->parkinglot->cfg.mohclass, NULL),
+ (!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
+ ? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0));
+ pu->moh_trys++;
+ }
+ goto std; /* XXX Ick: jumping into an else statement??? XXX */
}
- }
- if (y == nfds) {
- /* Not found */
- continue;
- }
-
- if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
- /* Next x */
- continue;
- }
-
- if (pfds[y].revents & POLLPRI) {
- ast_set_flag(chan, AST_FLAG_EXCEPTION);
- } else {
- ast_clear_flag(chan, AST_FLAG_EXCEPTION);
- }
- chan->fdno = x;
-
- /* See if they need servicing */
- f = ast_read(pu->chan);
- /* Hangup? */
- if (!f || (f->frametype == AST_FRAME_CONTROL
- && f->subclass.integer == AST_CONTROL_HANGUP)) {
- if (f) {
- ast_frfree(f);
- }
- post_manager_event("ParkedCallGiveUp", pu);
- ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp",
- NULL);
-
- /* There's a problem, hang them up */
- ast_verb(2, "%s got tired of being parked\n", chan->name);
- ast_hangup(chan);
-
- /* And take them out of the parking lot */
- parking_complete = 1;
- break;
- } else {
- /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
- ast_frfree(f);
- if (pu->hold_method == AST_CONTROL_HOLD
- && pu->moh_trys < 3
- && !chan->generatordata) {
- ast_debug(1,
- "MOH on parked call stopped by outside source. Restarting on channel %s.\n",
- chan->name);
- ast_indicate_data(chan, AST_CONTROL_HOLD,
- S_OR(pu->parkinglot->cfg.mohclass, NULL),
[... 315 lines stripped ...]
More information about the asterisk-commits
mailing list