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)
........

Merged revisions 366167 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@366168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
10
Kinsey Moore 13 years ago
parent 12581fed9f
commit 573b7a2d18

@ -11160,13 +11160,15 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc
AST_LIST_UNLOCK(&users); AST_LIST_UNLOCK(&users);
return CLI_FAILURE; return CLI_FAILURE;
} }
if (a->argc == 3) if (!context) {
ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
else { } else {
int count = 0; int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) { AST_LIST_TRAVERSE(&users, vmu, list) {
if (!strcmp(context, vmu->context)) if (!strcmp(context, vmu->context)) {
count++; count++;
break;
}
} }
if (count) { if (count) {
ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
@ -11180,7 +11182,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc
int newmsgs = 0, oldmsgs = 0; int newmsgs = 0, oldmsgs = 0;
char count[12], tmp[256] = ""; 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); snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs); inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count, sizeof(count), "%d", newmsgs); snprintf(count, sizeof(count), "%d", newmsgs);

@ -667,7 +667,9 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
break; break;
case AST_FRAME_DTMF_END: case AST_FRAME_DTMF_END:
if (!p->acknowledged && (f->subclass.integer == p->acceptdtmf)) { 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; p->acknowledged = 1;
ast_frfree(f); ast_frfree(f);
f = &answer_frame; f = &answer_frame;

@ -8935,7 +8935,9 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel); ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
/* If it's not us, return NULL immediately */ /* If it's not us, return NULL immediately */
if (ast != p->owner) { 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; f = &p->subs[idx].f;
return f; return f;
} }
@ -11760,14 +11762,13 @@ static void *do_monitor(void *data)
count = 0; count = 0;
for (i = iflist; i; i = i->next) { for (i = iflist; i; i = i->next) {
ast_mutex_lock(&i->lock); 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)) { if (analog_lib_handles(i->sig, i->radio, i->oprmode)) {
struct analog_pvt *p = i->sig_pvt; struct analog_pvt *p = i->sig_pvt;
if (!p) if (!p) {
ast_log(LOG_ERROR, "No sig_pvt?\n"); ast_log(LOG_ERROR, "No sig_pvt?\n");
} else if (!p->owner && !p->subs[SUB_REAL].owner) {
if (!p->owner && !p->subs[SUB_REAL].owner) {
/* This needs to be watched, as it lacks an owner */ /* This needs to be watched, as it lacks an owner */
pfds[count].fd = i->subs[SUB_REAL].dfd; pfds[count].fd = i->subs[SUB_REAL].dfd;
pfds[count].events = POLLPRI; pfds[count].events = POLLPRI;

@ -5376,7 +5376,7 @@ static int wait_for_peercallno(struct chan_iax2_pvt *pvt)
DEADLOCK_AVOIDANCE(&iaxsl[callno]); DEADLOCK_AVOIDANCE(&iaxsl[callno]);
pvt = iaxs[callno]; pvt = iaxs[callno];
} }
if (!pvt->peercallno) { if (!pvt || !pvt->peercallno) {
return -1; return -1;
} }
} }
@ -8767,6 +8767,7 @@ static void reg_source_db(struct iax2_peer *p)
expiry = strrchr(data, ':'); expiry = strrchr(data, ':');
if (!expiry) { if (!expiry) {
ast_log(LOG_NOTICE, "IAX/Registry astdb entry missing expiry: '%s'\n", data); ast_log(LOG_NOTICE, "IAX/Registry astdb entry missing expiry: '%s'\n", data);
return;
} }
*expiry++ = '\0'; *expiry++ = '\0';

@ -3179,7 +3179,7 @@ static int method_match(enum sipmethod id, const char *name)
int len = strlen(sip_methods[id].text); int len = strlen(sip_methods[id].text);
int l_name = name ? strlen(name) : 0; int l_name = name ? strlen(name) : 0;
/* true if the string is long enough, and ends with whitespace, and matches */ /* 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)); !strncasecmp(sip_methods[id].text, name, len));
} }
@ -3483,7 +3483,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_debug(1, "Target address %s is not local, substituting externaddr\n",
ast_sockaddr_stringify(them)); ast_sockaddr_stringify(them));
} else if (p) { } else {
/* no remapping, but we bind to a specific address, so use it. */ /* no remapping, but we bind to a specific address, so use it. */
switch (p->socket.type) { switch (p->socket.type) {
case SIP_TRANSPORT_TCP: case SIP_TRANSPORT_TCP:
@ -3514,8 +3514,6 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
ast_sockaddr_set_port(us, ast_sockaddr_port(&bindaddr)); 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)); ast_debug(3, "Setting SIP_TRANSPORT_%s with address %s\n", sip_get_transport(p->socket.type), ast_sockaddr_stringify(us));
} }
@ -3658,7 +3656,7 @@ static int retrans_pkt(const void *data)
pkt->retransid = -1; /* Kill this scheduler item */ 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 */ 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" 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", "Packet timed out after %dms with no response\n",
@ -7166,6 +7164,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
if (i->rtp) { if (i->rtp) {
ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0)); 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_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) { if (needvideo && i->vrtp) {
ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0)); ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
@ -7185,11 +7185,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
ast_format_copy(&tmp->writeformat, &fmt); ast_format_copy(&tmp->writeformat, &fmt);
ast_format_copy(&tmp->rawwriteformat, &fmt); ast_format_copy(&tmp->rawwriteformat, &fmt);
ast_rtp_instance_set_write_format(i->rtp, &fmt);
ast_format_copy(&tmp->readformat, &fmt); ast_format_copy(&tmp->readformat, &fmt);
ast_format_copy(&tmp->rawreadformat, &fmt); ast_format_copy(&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"); tmp->tech_pvt = dialog_ref(i, "sip_new: set chan->tech_pvt to i");
@ -8433,7 +8431,7 @@ static int sip_subscribe_mwi(const char *value, int lineno)
int portnum = 0; int portnum = 0;
enum sip_transport transport = SIP_TRANSPORT_UDP; enum sip_transport transport = SIP_TRANSPORT_UDP;
char buf[256] = ""; 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) { if (!value) {
return -1; return -1;
@ -8441,13 +8439,12 @@ static int sip_subscribe_mwi(const char *value, int lineno)
ast_copy_string(buf, value, sizeof(buf)); ast_copy_string(buf, value, sizeof(buf));
if (!(at = strstr(buf, "@"))) { username = buf;
return -1;
}
if ((hostname = strrchr(buf, '@'))) { if ((hostname = strrchr(buf, '@'))) {
*hostname++ = '\0'; *hostname++ = '\0';
username = buf; } else {
return -1;
} }
if ((secret = strchr(username, ':'))) { if ((secret = strchr(username, ':'))) {
@ -27082,8 +27079,12 @@ enum st_refresher st_get_refresher(struct sip_pvt *p)
*/ */
enum st_mode st_get_mode(struct sip_pvt *p, int no_cached) enum st_mode st_get_mode(struct sip_pvt *p, int no_cached)
{ {
if (!p->stimer) if (!p->stimer) {
sip_st_alloc(p); sip_st_alloc(p);
if (!p->stimer) {
return SESSION_TIMER_MODE_INVALID;
}
}
if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID) if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID)
return p->stimer->st_cached_mode; return p->stimer->st_cached_mode;

@ -1192,7 +1192,7 @@ struct iax_frame *iax_frame_new(int direction, int datalen, unsigned int cacheab
AST_LIST_TRAVERSE_SAFE_END; AST_LIST_TRAVERSE_SAFE_END;
} }
if (!fr) { 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 */ /* Make useless cache into something more useful */
AST_LIST_REMOVE(&iax_frames->list, smallest, list); AST_LIST_REMOVE(&iax_frames->list, smallest, list);
if (!(fr = ast_realloc(smallest, sizeof(*fr) + datalen))) { if (!(fr = ast_realloc(smallest, sizeof(*fr) + datalen))) {

@ -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; int res = AST_TEST_PASS;
char uri[1024]; char uri[1024];
@ -227,12 +227,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata { struct testdata {
char *desc; char *desc;
char *uri; char *uri;
char **userptr;
char **passptr;
char **hostportptr;
char **headersptr;
char **residueptr;
struct uriparams *paramsptr;
char *user; char *user;
char *pass; char *pass;
char *hostport; char *hostport;
@ -250,12 +244,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td1 = { struct testdata td1 = {
.desc = "no headers", .desc = "no headers",
.uri = "sip:user:secret@host:5060;param=discard;transport=tcp;param2=residue", .uri = "sip:user:secret@host:5060;param=discard;transport=tcp;param2=residue",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -269,12 +257,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td2 = { struct testdata td2 = {
.desc = "with headers", .desc = "with headers",
.uri = "sip:user:secret@host:5060;param=discard;transport=tcp;param2=discard2?header=blah&header2=blah2;param3=residue", .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 = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -288,12 +270,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td3 = { struct testdata td3 = {
.desc = "difficult user", .desc = "difficult user",
.uri = "sip:-_.!~*'()&=+$,;?/:secret@host:5060;transport=tcp", .uri = "sip:-_.!~*'()&=+$,;?/:secret@host:5060;transport=tcp",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "-_.!~*'()&=+$,;?/", .user = "-_.!~*'()&=+$,;?/",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -307,12 +283,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td4 = { struct testdata td4 = {
.desc = "difficult pass", .desc = "difficult pass",
.uri = "sip:user:-_.!~*'()&=+$,@host:5060;transport=tcp", .uri = "sip:user:-_.!~*'()&=+$,@host:5060;transport=tcp",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "-_.!~*'()&=+$,", .pass = "-_.!~*'()&=+$,",
.hostport = "host:5060", .hostport = "host:5060",
@ -326,12 +296,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td5 = { struct testdata td5 = {
.desc = "difficult host", .desc = "difficult host",
.uri = "sip:user:secret@1-1.a-1.:5060;transport=tcp", .uri = "sip:user:secret@1-1.a-1.:5060;transport=tcp",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "1-1.a-1.:5060", .hostport = "1-1.a-1.:5060",
@ -345,12 +309,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td6 = { struct testdata td6 = {
.desc = "difficult params near transport", .desc = "difficult params near transport",
.uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$;transport=tcp", .uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$;transport=tcp",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -364,12 +322,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td7 = { struct testdata td7 = {
.desc = "difficult params near headers", .desc = "difficult params near headers",
.uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$?header=blah&header2=blah2;-_.!~*'()[]/:&+$=residue", .uri = "sip:user:secret@host:5060;-_.!~*'()[]/:&+$=-_.!~*'()[]/:&+$?header=blah&header2=blah2;-_.!~*'()[]/:&+$=residue",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -383,12 +335,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td8 = { struct testdata td8 = {
.desc = "lr parameter", .desc = "lr parameter",
.uri = "sip:user:secret@host:5060;param=discard;lr?header=blah", .uri = "sip:user:secret@host:5060;param=discard;lr?header=blah",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -402,12 +348,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td9 = { struct testdata td9 = {
.desc = "alternative lr parameter", .desc = "alternative lr parameter",
.uri = "sip:user:secret@host:5060;param=discard;lr=yes?header=blah", .uri = "sip:user:secret@host:5060;param=discard;lr=yes?header=blah",
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -421,12 +361,6 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
struct testdata td10 = { struct testdata td10 = {
.desc = "no lr parameter", .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", .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 = &params,
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
.hostport = "host:5060", .hostport = "host:5060",
@ -469,19 +403,19 @@ AST_TEST_DEFINE(sip_parse_uri_fully_test)
params.lr = 0; params.lr = 0;
ast_copy_string(uri,testdataptr->uri,sizeof(uri)); ast_copy_string(uri,testdataptr->uri,sizeof(uri));
if (parse_uri_full(uri, "sip:,sips:", testdataptr->userptr, if (parse_uri_full(uri, "sip:,sips:", &user,
testdataptr->passptr, testdataptr->hostportptr, &pass, &hostport,
testdataptr->paramsptr, &params,
testdataptr->headersptr, &headers,
testdataptr->residueptr) || &residue) ||
((testdataptr->userptr) && strcmp(testdataptr->user, user)) || (user && strcmp(testdataptr->user, user)) ||
((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) || (pass && strcmp(testdataptr->pass, pass)) ||
((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) || (hostport && strcmp(testdataptr->hostport, hostport)) ||
((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) || (headers && strcmp(testdataptr->headers, headers)) ||
((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) || (residue && strcmp(testdataptr->residue, residue)) ||
((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) || (strcmp(testdataptr->params.transport,params.transport)) ||
((testdataptr->paramsptr) && (testdataptr->params.lr != params.lr)) || (testdataptr->params.lr != params.lr) ||
((testdataptr->paramsptr) && strcmp(testdataptr->params.user,params.user)) (strcmp(testdataptr->params.user,params.user))
) { ) {
ast_test_status_update(test, "Sub-Test: %s, failed.\n", testdataptr->desc); ast_test_status_update(test, "Sub-Test: %s, failed.\n", testdataptr->desc);
res = AST_TEST_FAIL; res = AST_TEST_FAIL;
@ -1220,13 +1154,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
struct testdata { struct testdata {
char *desc; char *desc;
char *uri; char *uri;
char **nameptr;
char **userptr;
char **passptr;
char **hostportptr;
char **headersptr;
char **residueptr;
struct uriparams *paramsptr;
char *name; char *name;
char *user; char *user;
char *pass; char *pass;
@ -1244,13 +1171,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
struct testdata td1 = { struct testdata td1 = {
.desc = "quotes and brackets", .desc = "quotes and brackets",
.uri = "\"name :@ \" <sip:user:secret@host:5060;param=discard;transport=tcp>;tag=tag", .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 = &params,
.name = "name :@ ", .name = "name :@ ",
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
@ -1265,13 +1185,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
struct testdata td2 = { struct testdata td2 = {
.desc = "no quotes", .desc = "no quotes",
.uri = "givenname familyname <sip:user:secret@host:5060;param=discard;transport=tcp>;expires=3600", .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 = &params,
.name = "givenname familyname", .name = "givenname familyname",
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
@ -1286,13 +1199,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
struct testdata td3 = { struct testdata td3 = {
.desc = "no brackets", .desc = "no brackets",
.uri = "sip:user:secret@host:5060;param=discard;transport=tcp;q=1", .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 = &params,
.name = "", .name = "",
.user = "user", .user = "user",
.pass = "secret", .pass = "secret",
@ -1307,13 +1213,6 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
struct testdata td4 = { struct testdata td4 = {
.desc = "just host", .desc = "just host",
.uri = "sips:host", .uri = "sips:host",
.nameptr = &name,
.userptr = &user,
.passptr = &pass,
.hostportptr = &hostport,
.headersptr = &headers,
.residueptr = &residue,
.paramsptr = &params,
.name = "", .name = "",
.user = "", .user = "",
.pass = "", .pass = "",
@ -1351,21 +1250,21 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
params.lr = 0; params.lr = 0;
ast_copy_string(uri,testdataptr->uri,sizeof(uri)); ast_copy_string(uri,testdataptr->uri,sizeof(uri));
if (parse_name_andor_addr(uri, "sip:,sips:", if (parse_name_andor_addr(uri, "sip:,sips:",
testdataptr->nameptr, &name,
testdataptr->userptr, &user,
testdataptr->passptr, &pass,
testdataptr->hostportptr, &hostport,
testdataptr->paramsptr, &params,
testdataptr->headersptr, &headers,
testdataptr->residueptr) || &residue) ||
((testdataptr->nameptr) && strcmp(testdataptr->name, name)) || (name && strcmp(testdataptr->name, name)) ||
((testdataptr->userptr) && strcmp(testdataptr->user, user)) || (user && strcmp(testdataptr->user, user)) ||
((testdataptr->passptr) && strcmp(testdataptr->pass, pass)) || (pass && strcmp(testdataptr->pass, pass)) ||
((testdataptr->hostportptr) && strcmp(testdataptr->hostport, hostport)) || (hostport && strcmp(testdataptr->hostport, hostport)) ||
((testdataptr->headersptr) && strcmp(testdataptr->headers, headers)) || (headers && strcmp(testdataptr->headers, headers)) ||
((testdataptr->residueptr) && strcmp(testdataptr->residue, residue)) || (residue && strcmp(testdataptr->residue, residue)) ||
((testdataptr->paramsptr) && strcmp(testdataptr->params.transport,params.transport)) || (strcmp(testdataptr->params.transport,params.transport)) ||
((testdataptr->paramsptr) && strcmp(testdataptr->params.user,params.user)) (strcmp(testdataptr->params.user,params.user))
) { ) {
ast_test_status_update(test, "Sub-Test: %s,failed.\n", testdataptr->desc); ast_test_status_update(test, "Sub-Test: %s,failed.\n", testdataptr->desc);
res = AST_TEST_FAIL; 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(sip_parse_uri_test);
AST_TEST_REGISTER(get_in_brackets_test); AST_TEST_REGISTER(get_in_brackets_test);
AST_TEST_REGISTER(get_name_and_number_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_name_andor_addr_test);
AST_TEST_REGISTER(parse_contact_header_test); AST_TEST_REGISTER(parse_contact_header_test);
AST_TEST_REGISTER(sip_parse_options_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_calleridname_test);
AST_TEST_UNREGISTER(get_in_brackets_test); AST_TEST_UNREGISTER(get_in_brackets_test);
AST_TEST_UNREGISTER(get_name_and_number_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_name_andor_addr_test);
AST_TEST_UNREGISTER(parse_contact_header_test); AST_TEST_UNREGISTER(parse_contact_header_test);
AST_TEST_UNREGISTER(sip_parse_options_test); AST_TEST_UNREGISTER(sip_parse_options_test);

@ -373,10 +373,15 @@ static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) 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; struct channel_lock_frame *clframe;
AST_LIST_HEAD(, channel_lock_frame) *list; AST_LIST_HEAD(, channel_lock_frame) *list;
if (!chan) {
return -1;
}
lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
if (!lock_store) { if (!lock_store) {
ast_log(LOG_WARNING, "No datastore for dialplan locks. Nothing was ever locked!\n"); ast_log(LOG_WARNING, "No datastore for dialplan locks. Nothing was ever locked!\n");
ast_copy_string(buf, "0", len); ast_copy_string(buf, "0", len);
@ -417,26 +422,24 @@ static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, ch
static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{ {
if (chan) if (!chan) {
ast_autoservice_start(chan); return -1;
}
ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 0) ? "0" : "1", len); ast_copy_string(buf, get_lock(chan, data, 0) ? "0" : "1", len);
ast_autoservice_stop(chan);
if (chan)
ast_autoservice_stop(chan);
return 0; return 0;
} }
static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{ {
if (chan) if (!chan) {
ast_autoservice_start(chan); return -1;
}
ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 1) ? "0" : "1", len); ast_copy_string(buf, get_lock(chan, data, 1) ? "0" : "1", len);
ast_autoservice_stop(chan);
if (chan)
ast_autoservice_stop(chan);
return 0; return 0;
} }

@ -202,6 +202,11 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
struct speex_direction_info **sdi = NULL; struct speex_direction_info **sdi = NULL;
int is_new = 0; 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); ast_channel_lock(chan);
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) { if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
ast_channel_unlock(chan); ast_channel_unlock(chan);
@ -226,15 +231,8 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
if (!strcasecmp(data, "rx")) { if (!strcasecmp(data, "rx")) {
sdi = &si->rx; sdi = &si->rx;
} else if (!strcasecmp(data, "tx")) {
sdi = &si->tx;
} else { } else {
ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd); sdi = &si->tx;
if (is_new) {
ast_datastore_free(datastore);
return -1;
}
} }
if (!*sdi) { if (!*sdi) {

@ -572,6 +572,9 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
long pause_restart_point = 0; long pause_restart_point = 0;
long offset = 0; long offset = 0;
if (!file) {
return -1;
}
if (offsetms) { if (offsetms) {
offset = *offsetms * 8; /* XXX Assumes 8kHz */ offset = *offsetms * 8; /* XXX Assumes 8kHz */
} }
@ -603,12 +606,10 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
res = ast_answer(chan); res = ast_answer(chan);
} }
if (file) { if ((end = strchr(file, ':'))) {
if ((end = strchr(file, ':'))) { if (!strcasecmp(end, ":end")) {
if (!strcasecmp(end, ":end")) { *end = '\0';
*end = '\0'; end++;
end++;
}
} }
} }

@ -573,7 +573,9 @@ void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from)
lfrom = lfrom->next; lfrom = lfrom->next;
} }
/* rip off the last entry and put a copy of the to at the end */ /* 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; from = lfrom;
} else { } else {
/* save copy of the current *to cdr */ /* save copy of the current *to cdr */
@ -589,10 +591,11 @@ void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from)
} }
from->next = NULL; from->next = NULL;
/* rip off the last entry and put a copy of the to at the end */ /* 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); to = to->next = ast_cdr_dup(&tcdr);
else } else if (llfrom) {
to = llfrom->next = ast_cdr_dup(&tcdr); to = llfrom->next = ast_cdr_dup(&tcdr);
}
from = lfrom; from = lfrom;
} }
} }

@ -3183,16 +3183,19 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
int fdno; int fdno;
} *fdmap = NULL; } *fdmap = NULL;
if ((sz = n * AST_MAX_FDS + nfds)) {
pfds = alloca(sizeof(*pfds) * sz);
fdmap = alloca(sizeof(*fdmap) * sz);
}
if (outfd) if (outfd)
*outfd = -99999; *outfd = -99999;
if (exception) if (exception)
*exception = 0; *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 */ /* Perform any pending masquerades */
for (x = 0; x < n; x++) { for (x = 0; x < n; x++) {
if (c[x]->masq && ast_do_masquerade(c[x])) { if (c[x]->masq && ast_do_masquerade(c[x])) {

@ -562,7 +562,11 @@ struct ast_variable *ast_variable_browse(const struct ast_config *config, const
{ {
struct ast_category *cat = NULL; 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; cat = config->last_browse;
} else { } else {
cat = ast_category_get(config, category); cat = ast_category_get(config, category);
@ -1896,7 +1900,7 @@ int ast_config_text_file_save(const char *configfile, const struct ast_config *c
/* Dump section with any appropriate comment */ /* Dump section with any appropriate comment */
for (cmt = cat->precomments; cmt; cmt=cmt->next) { for (cmt = cat->precomments; cmt; cmt=cmt->next) {
char *cmtp = cmt->cmt; char *cmtp = cmt->cmt;
while (*cmtp == ';' && *(cmtp+1) == '!') { while (cmtp && *cmtp == ';' && *(cmtp+1) == '!') {
char *cmtp2 = strchr(cmtp+1, '\n'); char *cmtp2 = strchr(cmtp+1, '\n');
if (cmtp2) if (cmtp2)
cmtp = cmtp2+1; cmtp = cmtp2+1;

@ -2496,18 +2496,20 @@ struct ast_data_iterator *ast_data_iterator_init(struct ast_data *tree,
struct ast_data *internal = tree; struct ast_data *internal = tree;
char *path, *ptr = NULL; char *path, *ptr = NULL;
if (!elements) {
return NULL;
}
/* tree is the node we want to use to iterate? or we are going /* tree is the node we want to use to iterate? or we are going
* to iterate thow an internal node? */ * to iterate thow an internal node? */
if (elements) { path = ast_strdupa(elements);
path = ast_strdupa(elements);
ptr = strrchr(path, '/');
ptr = strrchr(path, '/'); if (ptr) {
if (ptr) { *ptr = '\0';
*ptr = '\0'; internal = data_result_get_node(tree, path);
internal = data_result_get_node(tree, path); if (!internal) {
if (!internal) { return NULL;
return NULL;
}
} }
} }

@ -330,9 +330,7 @@ static enum ast_device_state _ast_device_state(const char *device, int check_cac
/* We have a provider */ /* We have a provider */
number = tech; number = tech;
tech = NULL; tech = NULL;
}
if (provider) {
ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number); ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
return getproviderstate(provider, number); return getproviderstate(provider, number);
} }

@ -1286,8 +1286,9 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
break; break;
} }
/* realloc inside one of the append functions failed */
if (!event) { if (!event) {
break; return NULL;
} }
} }

@ -2060,6 +2060,9 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
struct ast_channel *caller_chan, *callee_chan; struct ast_channel *caller_chan, *callee_chan;
const char *automon_message_start = NULL; const char *automon_message_start = NULL;
const char *automon_message_stop = 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) { if (!monitor_ok) {
ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n"); ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
@ -2073,10 +2076,13 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
} }
set_peers(&caller_chan, &callee_chan, peer, chan, sense); set_peers(&caller_chan, &callee_chan, peer, chan, sense);
if (caller_chan) { /* Find extra messages */ if (!caller_chan || !callee_chan) {
automon_message_start = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_START"); ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
automon_message_stop = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_MESSAGE_STOP"); 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 (!ast_strlen_zero(courtesytone)) { /* Play courtesy tone if configured */
if(play_message_in_bridged_call(caller_chan, callee_chan, courtesytone) == -1) { if(play_message_in_bridged_call(caller_chan, callee_chan, courtesytone) == -1) {
@ -2093,58 +2099,53 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
return AST_FEATURE_RETURN_SUCCESS; return AST_FEATURE_RETURN_SUCCESS;
} }
if (caller_chan && callee_chan) { touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT");
const char *touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT"); touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR");
const char *touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR"); touch_monitor_prefix = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_PREFIX");
const char *touch_monitor_prefix = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_PREFIX");
if (!touch_format) if (!touch_format)
touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT"); touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT");
if (!touch_monitor) if (!touch_monitor)
touch_monitor = pbx_builtin_getvar_helper(callee_chan, "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 (!touch_monitor_prefix)
if (args[x] == '/') touch_monitor_prefix = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_PREFIX");
args[x] = '-';
}
ast_verb(4, "User hit '%s' to record call. filename: %s\n", code, args);
pbx_exec(callee_chan, monitor_app, args); if (touch_monitor) {
pbx_builtin_setvar_helper(callee_chan, "TOUCH_MONITOR_OUTPUT", touch_filename); len = strlen(touch_monitor) + 50;
pbx_builtin_setvar_helper(caller_chan, "TOUCH_MONITOR_OUTPUT", touch_filename); 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);
}
if (!ast_strlen_zero(automon_message_start)) { /* Play start message for both channels */ for(x = 0; x < strlen(args); x++) {
play_message_in_bridged_call(caller_chan, callee_chan, automon_message_start); if (args[x] == '/')
} args[x] = '-';
return AST_FEATURE_RETURN_SUCCESS;
} }
ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n"); ast_verb(4, "User hit '%s' to record call. filename: %s\n", code, args);
return -1;
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) 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 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
ast_autoservice_start(idle); ast_autoservice_start(idle);
ast_autoservice_ignore(idle, AST_FRAME_DTMF_END); ast_autoservice_ignore(idle, AST_FRAME_DTMF_END);
if(work && idle) { pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", idle->name);
pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", idle->name); pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", work->name);
pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", work->name); pbx_builtin_setvar_helper(work, "DYNAMIC_FEATURENAME", feature->sname);
pbx_builtin_setvar_helper(work, "DYNAMIC_FEATURENAME", feature->sname); pbx_builtin_setvar_helper(idle, "DYNAMIC_FEATURENAME", feature->sname);
pbx_builtin_setvar_helper(idle, "DYNAMIC_FEATURENAME", feature->sname);
}
if (!ast_strlen_zero(feature->moh_class)) if (!ast_strlen_zero(feature->moh_class))
ast_moh_start(idle, feature->moh_class, NULL); ast_moh_start(idle, feature->moh_class, NULL);
@ -3284,7 +3283,9 @@ static int feature_interpret_helper(struct ast_channel *chan, struct ast_channel
if (operation) { if (operation) {
res = fge->feature->operation(chan, peer, config, code, sense, fge->feature); 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) { if (res != AST_FEATURE_RETURN_KEEPTRYING) {
AST_RWLIST_UNLOCK(&feature_groups); AST_RWLIST_UNLOCK(&feature_groups);
break; break;
@ -4745,76 +4746,80 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
/* And take them out of the parking lot */ /* And take them out of the parking lot */
parking_complete = 1; parking_complete = 1;
} else { /* still within parking time, process descriptors */ } else { /* still within parking time, process descriptors */
for (x = 0; x < AST_MAX_FDS; x++) { x = 0;
struct ast_frame *f; if (pfds) {
int y; for (; x < AST_MAX_FDS; x++) {
struct ast_frame *f;
if (chan->fds[x] == -1) { int y;
continue; /* nothing on this descriptor */
} if (chan->fds[x] == -1) {
continue; /* nothing on this descriptor */
}
for (y = 0; y < nfds; y++) { for (y = 0; y < nfds; y++) {
if (pfds[y].fd == chan->fds[x]) { if (pfds[y].fd == chan->fds[x]) {
/* Found poll record! */ /* Found poll record! */
break; break;
}
}
if (y == nfds) {
/* Not found */
continue;
} }
}
if (y == nfds) {
/* Not found */
continue;
}
if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) { if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
/* Next x */ /* Next x */
continue; continue;
} }
if (pfds[y].revents & POLLPRI) { if (pfds[y].revents & POLLPRI) {
ast_set_flag(chan, AST_FLAG_EXCEPTION); ast_set_flag(chan, AST_FLAG_EXCEPTION);
} else { } else {
ast_clear_flag(chan, AST_FLAG_EXCEPTION); 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); chan->fdno = x;
ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp",
NULL); /* 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 */ /* There's a problem, hang them up */
ast_verb(2, "%s got tired of being parked\n", chan->name); ast_verb(2, "%s got tired of being parked\n", chan->name);
ast_hangup(chan); ast_hangup(chan);
/* And take them out of the parking lot */ /* And take them out of the parking lot */
parking_complete = 1; parking_complete = 1;
break; break;
} else { } else {
/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */ /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
ast_frfree(f); ast_frfree(f);
if (pu->hold_method == AST_CONTROL_HOLD if (pu->hold_method == AST_CONTROL_HOLD
&& pu->moh_trys < 3 && pu->moh_trys < 3
&& !chan->generatordata) { && !chan->generatordata) {
ast_debug(1, ast_debug(1,
"MOH on parked call stopped by outside source. Restarting on channel %s.\n", "MOH on parked call stopped by outside source. Restarting on channel %s.\n",
chan->name); chan->name);
ast_indicate_data(chan, AST_CONTROL_HOLD, ast_indicate_data(chan, AST_CONTROL_HOLD,
S_OR(pu->parkinglot->cfg.mohclass, NULL), S_OR(pu->parkinglot->cfg.mohclass, NULL),
(!ast_strlen_zero(pu->parkinglot->cfg.mohclass) (!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0)); ? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0));
pu->moh_trys++; pu->moh_trys++;
}
goto std; /* XXX Ick: jumping into an else statement??? XXX */
} }
goto std; /* XXX Ick: jumping into an else statement??? XXX */ } /* End for */
} }
} /* End for */
if (x >= AST_MAX_FDS) { if (x >= AST_MAX_FDS) {
std: for (x = 0; x < AST_MAX_FDS; x++) { /* mark fds for next round */ std:
for (x = 0; x < AST_MAX_FDS; x++) { /* mark fds for next round */
if (chan->fds[x] > -1) { if (chan->fds[x] > -1) {
void *tmp = ast_realloc(*new_pfds, void *tmp = ast_realloc(*new_pfds,
(*new_nfds + 1) * sizeof(struct pollfd)); (*new_nfds + 1) * sizeof(struct pollfd));

@ -4579,10 +4579,22 @@ static int action_reload(struct mansession *s, const struct message *m)
const char *module = astman_get_header(m, "Module"); const char *module = astman_get_header(m, "Module");
int res = ast_module_reload(S_OR(module, NULL)); int res = ast_module_reload(S_OR(module, NULL));
if (res == 2) { switch (res) {
case -1:
astman_send_error(s, m, "A reload is in progress");
break;
case 0:
astman_send_error(s, m, "No such module");
break;
case 1:
astman_send_error(s, m, "Module does not support reload");
break;
case 2:
astman_send_ack(s, m, "Module Reloaded"); astman_send_ack(s, m, "Module Reloaded");
} else { break;
astman_send_error(s, m, s == 0 ? "No such module" : "Module does not support reload"); default:
astman_send_error(s, m, "An unknown error occurred");
break;
} }
return 0; return 0;
} }
@ -6957,7 +6969,7 @@ static int __init_manager(int reload)
if (user_writetimeout) { if (user_writetimeout) {
int value = atoi(user_writetimeout); int value = atoi(user_writetimeout);
if (value < 100) { if (value < 100) {
ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at users.conf line %d\n", var->value, var->lineno); ast_log(LOG_WARNING, "Invalid writetimeout value '%d' in users.conf\n", value);
} else { } else {
user->writetimeout = value; user->writetimeout = value;
} }

@ -1733,8 +1733,9 @@ static void cli_match_char_tree(struct match_char *node, char *prefix, int fd)
extenstr[0] = '\0'; extenstr[0] = '\0';
if (node && node->exten) if (node->exten) {
snprintf(extenstr, sizeof(extenstr), "(%p)", node->exten); snprintf(extenstr, sizeof(extenstr), "(%p)", node->exten);
}
if (strlen(node->x) > 1) { if (strlen(node->x) > 1) {
ast_cli(fd, "%s[%s]:%c:%c:%d:%s%s%s\n", prefix, node->x, node->is_pattern ? 'Y' : 'N', ast_cli(fd, "%s[%s]:%c:%c:%d:%s%s%s\n", prefix, node->x, node->is_pattern ? 'Y' : 'N',
@ -9693,6 +9694,11 @@ static int pbx_builtin_gotoiftime(struct ast_channel *chan, const char *data)
struct timeval tv = ast_tvnow(); struct timeval tv = ast_tvnow();
long timesecs; long timesecs;
if (!chan) {
ast_log(LOG_WARNING, "GotoIfTime requires a channel on which to operate\n");
return -1;
}
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n"); ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
return -1; return -1;
@ -9700,17 +9706,16 @@ static int pbx_builtin_gotoiftime(struct ast_channel *chan, const char *data)
ts = s = ast_strdupa(data); ts = s = ast_strdupa(data);
if (chan) { ast_channel_lock(chan);
ast_channel_lock(chan); if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) {
if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) { tv.tv_sec = timesecs;
tv.tv_sec = timesecs; } else if (ctime) {
} else if (ctime) { ast_log(LOG_WARNING, "Using current time to evaluate\n");
ast_log(LOG_WARNING, "Using current time to evaluate\n"); /* Reset when unparseable */
/* Reset when unparseable */ pbx_builtin_setvar_helper(chan, "TESTTIME", NULL);
pbx_builtin_setvar_helper(chan, "TESTTIME", NULL);
}
ast_channel_unlock(chan);
} }
ast_channel_unlock(chan);
/* Separate the Goto path */ /* Separate the Goto path */
strsep(&ts, "?"); strsep(&ts, "?");
branch1 = strsep(&ts,":"); branch1 = strsep(&ts,":");

@ -412,8 +412,10 @@ struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_se
return handle_tcptls_connection(tcptls_session); return handle_tcptls_connection(tcptls_session);
client_start_error: client_start_error:
close(desc->accept_fd); if (desc) {
desc->accept_fd = -1; close(desc->accept_fd);
desc->accept_fd = -1;
}
if (tcptls_session) { if (tcptls_session) {
ao2_ref(tcptls_session, -1); ao2_ref(tcptls_session, -1);
} }

@ -976,26 +976,28 @@ static char *xmldoc_get_syntax_cmd(struct ast_xml_node *fixnode, const char *nam
/* is this a recursive parameter. */ /* is this a recursive parameter. */
paramname = xmldoc_get_syntax_cmd(node, "", 0); paramname = xmldoc_get_syntax_cmd(node, "", 0);
isenum = 1; isenum = 1;
} else if (!xmldoc_has_inside(node, "enumlist")) {
/* this is a simple parameter. */
attrname = ast_xml_get_attribute(node, "name");
if (!attrname) {
/* ignore this bogus parameter and continue. */
continue;
}
paramname = ast_strdup(attrname);
ast_xml_free_attr(attrname);
isenum = 0;
} else { } else {
/* parse enumlist (note that this is a special enumlist
that is used to describe a syntax like {<param1>|<param2>|...} */
for (tmpnode = ast_xml_node_get_children(node); tmpnode; tmpnode = ast_xml_node_get_next(tmpnode)) { for (tmpnode = ast_xml_node_get_children(node); tmpnode; tmpnode = ast_xml_node_get_next(tmpnode)) {
if (!strcasecmp(ast_xml_node_get_name(tmpnode), "enumlist")) { if (!strcasecmp(ast_xml_node_get_name(tmpnode), "enumlist")) {
break; break;
} }
} }
paramname = xmldoc_parse_cmd_enumlist(tmpnode); if (tmpnode) {
isenum = 1; /* parse enumlist (note that this is a special enumlist
that is used to describe a syntax like {<param1>|<param2>|...} */
paramname = xmldoc_parse_cmd_enumlist(tmpnode);
isenum = 1;
} else {
/* this is a simple parameter. */
attrname = ast_xml_get_attribute(node, "name");
if (!attrname) {
/* ignore this bogus parameter and continue. */
continue;
}
paramname = ast_strdup(attrname);
ast_xml_free_attr(attrname);
isenum = 0;
}
} }
/* Is this parameter required? */ /* Is this parameter required? */

@ -512,8 +512,10 @@ int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned
ied->buf[ied->pos++] = ie; ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen; ied->buf[ied->pos++] = datalen;
ied->buf[ied->pos++] = cause; ied->buf[ied->pos++] = cause;
memcpy(ied->buf + ied->pos, data, datalen-1); if (data) {
ied->pos += datalen-1; memcpy(ied->buf + ied->pos, data, datalen-1);
ied->pos += datalen-1;
}
return 0; return 0;
} }
@ -531,8 +533,10 @@ int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned s
flags = htons(flags); flags = htons(flags);
memcpy(ied->buf + ied->pos, &flags, sizeof(flags)); memcpy(ied->buf + ied->pos, &flags, sizeof(flags));
ied->pos += 2; ied->pos += 2;
memcpy(ied->buf + ied->pos, data, datalen-1); if (data) {
ied->pos += datalen-2; memcpy(ied->buf + ied->pos, data, datalen-2);
ied->pos += datalen-2;
}
return 0; return 0;
} }

@ -1014,7 +1014,7 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
totallen += (ies->eidcount - skipfirst) * sizeof(dundi_eid); totallen += (ies->eidcount - skipfirst) * sizeof(dundi_eid);
st = ast_calloc(1, totallen); st = ast_calloc(1, totallen);
if (st) { if (st) {
ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context)); ast_copy_string(st->called_context, dr.dcontext, sizeof(st->called_context));
ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number)); ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number));
st->trans = trans; st->trans = trans;
st->ttl = ies->ttl - 1; st->ttl = ies->ttl - 1;

@ -1160,7 +1160,11 @@ static pval *get_goto_target(pval *item)
pval *curr_ext = get_extension_or_contxt(item); /* containing exten, or macro */ pval *curr_ext = get_extension_or_contxt(item); /* containing exten, or macro */
pval *curr_cont; pval *curr_cont;
if (item->u1.list && !item->u1.list->next && !strstr((item->u1.list)->u1.str,"${")) { if (!item->u1.list) {
return NULL;
}
if (!item->u1.list->next && !strstr((item->u1.list)->u1.str,"${")) {
struct pval *x = find_label_in_current_extension((char*)((item->u1.list)->u1.str), curr_ext); struct pval *x = find_label_in_current_extension((char*)((item->u1.list)->u1.str), curr_ext);
return x; return x;
} }
@ -5882,7 +5886,7 @@ pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement )
{ {
if (!pvalCheckType(p, "pvalGlobalsWalkStatements", PV_GLOBALS)) if (!pvalCheckType(p, "pvalGlobalsWalkStatements", PV_GLOBALS))
return 0; return 0;
if (!next_statement) { if (!*next_statement) {
*next_statement = p; *next_statement = p;
return p; return p;
} else { } else {
@ -5903,7 +5907,7 @@ void pvalTopLevAddObject( pval *p, pval *contextOrObj )
pval *pvalTopLevWalkObjects(pval *p, pval **next_obj ) pval *pvalTopLevWalkObjects(pval *p, pval **next_obj )
{ {
if (!next_obj) { if (!*next_obj) {
*next_obj = p; *next_obj = p;
return p; return p;
} else { } else {

@ -133,6 +133,7 @@ static icalcomponent *fetch_icalendar(struct icalendar_pvt *pvt)
if (!pvt) { if (!pvt) {
ast_log(LOG_ERROR, "There is no private!\n"); ast_log(LOG_ERROR, "There is no private!\n");
return NULL;
} }
if (!(response = ast_str_create(512))) { if (!(response = ast_str_create(512))) {

@ -378,7 +378,9 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) { O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
ast_log(LOG_WARNING, "Could not create file %s\n", ast_log(LOG_WARNING, "Could not create file %s\n",
monitor->write_filename); monitor->write_filename);
ast_closestream(monitor->read_stream); if (monitor->read_stream) {
ast_closestream(monitor->read_stream);
}
ast_free(monitor); ast_free(monitor);
UNLOCK_IF_NEEDED(chan, need_lock); UNLOCK_IF_NEEDED(chan, need_lock);
return -1; return -1;

@ -365,6 +365,10 @@ static int mark_transaction_active(struct ast_channel *chan, struct odbc_txn_fra
chan = tx->owner; chan = tx->owner;
} }
if (!chan) {
return -1;
}
ast_channel_lock(chan); ast_channel_lock(chan);
if (!(txn_store = ast_channel_datastore_find(chan, &txn_info, NULL))) { if (!(txn_store = ast_channel_datastore_find(chan, &txn_info, NULL))) {
ast_channel_unlock(chan); ast_channel_unlock(chan);

Loading…
Cancel
Save