[asterisk-commits] jrose: branch 1.8 r366094 - in /branches/1.8: apps/ channels/ funcs/ main/ re...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 10 11:47:29 CDT 2012
Author: jrose
Date: Thu May 10 11:47:17 2012
New Revision: 366094
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366094
Log:
Coverity Report: Fix issues for error type CHECKED_RETURN for core
(issue ASTERISK-19658)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/1905/
Modified:
branches/1.8/apps/app_queue.c
branches/1.8/apps/app_voicemail.c
branches/1.8/channels/chan_iax2.c
branches/1.8/channels/chan_sip.c
branches/1.8/channels/iax2-provision.c
branches/1.8/channels/sig_analog.c
branches/1.8/funcs/func_devstate.c
branches/1.8/funcs/func_lock.c
branches/1.8/main/acl.c
branches/1.8/main/asterisk.c
branches/1.8/main/db.c
branches/1.8/main/features.c
branches/1.8/main/pbx.c
branches/1.8/main/xmldoc.c
branches/1.8/res/ael/ael.flex
Modified: branches/1.8/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_queue.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/apps/app_queue.c (original)
+++ branches/1.8/apps/app_queue.c Thu May 10 11:47:17 2012
@@ -4631,7 +4631,9 @@
res2 |= ast_safe_sleep(peer, qe->parent->memberdelay * 1000);
}
if (!res2 && announce) {
- play_file(peer, announce);
+ if (play_file(peer, announce) < 0) {
+ ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", announce, peer->name);
+ }
}
if (!res2 && qe->parent->reportholdtime) {
if (!play_file(peer, qe->parent->sound_reporthold)) {
@@ -4642,11 +4644,15 @@
holdtimesecs = abs((now - qe->start) % 60);
if (holdtime > 0) {
ast_say_number(peer, holdtime, AST_DIGIT_ANY, peer->language, NULL);
- play_file(peer, qe->parent->sound_minutes);
+ if (play_file(peer, qe->parent->sound_minutes) < 0) {
+ ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", qe->parent->sound_minutes, peer->name);
+ }
}
if (holdtimesecs > 1) {
ast_say_number(peer, holdtimesecs, AST_DIGIT_ANY, peer->language, NULL);
- play_file(peer, qe->parent->sound_seconds);
+ if (play_file(peer, qe->parent->sound_seconds) < 0) {
+ ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", qe->parent->sound_seconds, peer->name);
+ }
}
}
}
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=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/apps/app_voicemail.c (original)
+++ branches/1.8/apps/app_voicemail.c Thu May 10 11:47:17 2012
@@ -6892,7 +6892,10 @@
strncat(vms->introfn, "intro", sizeof(vms->introfn));
ast_play_and_wait(chan, INTRO);
ast_play_and_wait(chan, "beep");
- play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *) duration, NULL, NULL, record_gain, vms, flag);
+ cmd = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *) duration, NULL, NULL, record_gain, vms, flag);
+ if (cmd == -1) {
+ break;
+ }
cmd = 't';
#else
@@ -9457,7 +9460,10 @@
retries = 0;
RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
if (ast_fileexists(prefile, NULL, NULL) <= 0) {
- play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+ cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+ if (cmd == -1) {
+ break;
+ }
cmd = 't';
} else {
switch (cmd) {
@@ -11561,6 +11567,7 @@
static void start_poll_thread(void)
{
+ int errcode;
mwi_sub_sub = ast_event_subscribe(AST_EVENT_SUB, mwi_sub_event_cb, "Voicemail MWI subscription", NULL,
AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI,
AST_EVENT_IE_END);
@@ -11574,7 +11581,9 @@
poll_thread_run = 1;
- ast_pthread_create(&poll_thread, NULL, mb_poll_thread, NULL);
+ if ((errcode = ast_pthread_create(&poll_thread, NULL, mb_poll_thread, NULL))) {
+ ast_log(LOG_ERROR, "Could not create thread: %s\n", strerror(errcode));
+ }
}
static void stop_poll_thread(void)
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=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/channels/chan_iax2.c (original)
+++ branches/1.8/channels/chan_iax2.c Thu May 10 11:47:17 2012
@@ -4390,11 +4390,13 @@
/* Whoops, we weren't supposed to exist! */
peer = peer_unref(peer);
break;
- }
+ }
} else if (!strcasecmp(tmp->name, "regseconds")) {
ast_get_time_t(tmp->value, ®seconds, 0, NULL);
} else if (!strcasecmp(tmp->name, "ipaddr")) {
- ast_sockaddr_parse(&peer->addr, tmp->value, PARSE_PORT_IGNORE);
+ if (!ast_sockaddr_parse(&peer->addr, tmp->value, PARSE_PORT_IGNORE)) {
+ ast_log(LOG_WARNING, "Failed to parse sockaddr '%s' for ipaddr of realtime peer '%s'\n", tmp->value, tmp->name);
+ }
} else if (!strcasecmp(tmp->name, "port")) {
ast_sockaddr_set_port(&peer->addr, atoi(tmp->value));
} else if (!strcasecmp(tmp->name, "host")) {
@@ -11634,6 +11636,7 @@
ast_mutex_destroy(&thread->init_lock);
ast_cond_destroy(&thread->init_cond);
ast_free(thread);
+ /* Ignore check_return warning from Coverity for ast_atomic_dec_and_test below */
ast_atomic_dec_and_test(&iaxactivethreadcount);
}
@@ -12212,7 +12215,10 @@
AST_LIST_UNLOCK(&idle_list);
}
}
- ast_pthread_create_background(&netthreadid, NULL, network_thread, NULL);
+ if (ast_pthread_create_background(&netthreadid, NULL, network_thread, NULL)) {
+ ast_log(LOG_ERROR, "Failed to create new thread!\n");
+ return -1;
+ }
ast_verb(2, "%d helper threads started\n", threadcount);
return 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=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Thu May 10 11:47:17 2012
@@ -15913,7 +15913,9 @@
p->sa = p->recv;
}
- ast_sockaddr_resolve_first(&tmp, c, 0);
+ if (ast_sockaddr_resolve_first(&tmp, c, 0)) {
+ ast_log(LOG_WARNING, "Could not resolve socket address for '%s'\n", c);
+ }
port = ast_sockaddr_port(&tmp);
ast_sockaddr_set_port(&p->sa,
port != 0 ? port : STANDARD_SIP_PORT);
@@ -16222,6 +16224,7 @@
/* Finally, apply the guest policy */
if (sip_cfg.allowguest) {
+ /* Ignore check_return warning from Coverity for get_rpid below. */
get_rpid(p, req);
p->rtptimeout = global_rtptimeout;
p->rtpholdtimeout = global_rtpholdtimeout;
@@ -17972,7 +17975,10 @@
return 0; /* don't care, we scan all channels */
}
- ast_rtp_instance_get_stats(cur->rtp, &stats, AST_RTP_INSTANCE_STAT_ALL);
+ if (ast_rtp_instance_get_stats(cur->rtp, &stats, AST_RTP_INSTANCE_STAT_ALL)) {
+ ast_log(LOG_WARNING, "Could not get RTP stats.\n");
+ return 0;
+ }
if (c && c->cdr && !ast_tvzero(c->cdr->start)) {
duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
Modified: branches/1.8/channels/iax2-provision.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/iax2-provision.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/channels/iax2-provision.c (original)
+++ branches/1.8/channels/iax2-provision.c Thu May 10 11:47:17 2012
@@ -258,7 +258,11 @@
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&provlock);
- ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp));
+ if (!(ast_db_get("iax/provisioning/cache", template, tmp, sizeof(tmp)))) {
+ ast_log(LOG_ERROR, "ast_db_get failed to retrieve iax/provisioning/cache\n");
+ ast_mutex_unlock(&provlock);
+ return -1;
+ }
if (sscanf(tmp, "v%30x", version) != 1) {
if (strcmp(tmp, "u")) {
ret = iax_provision_build(&ied, version, template, force);
Modified: branches/1.8/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sig_analog.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/channels/sig_analog.c (original)
+++ branches/1.8/channels/sig_analog.c Thu May 10 11:47:17 2012
@@ -2741,7 +2741,10 @@
analog_train_echocanceller(p);
ast_copy_string(p->dop.dialstr, p->echorest, sizeof(p->dop.dialstr));
p->dop.op = ANALOG_DIAL_OP_REPLACE;
- analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
+ if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
+ int dial_err = errno;
+ ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(dial_err));
+ }
p->echobreak = 0;
} else {
analog_set_dialing(p, 0);
Modified: branches/1.8/funcs/func_devstate.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_devstate.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/funcs/func_devstate.c (original)
+++ branches/1.8/funcs/func_devstate.c Thu May 10 11:47:17 2012
@@ -187,6 +187,7 @@
{
char buf[256] = "";
+ /* Ignore check_return warning from Coverity fow ast_db_get below */
ast_db_get(astdb_family, data, buf, sizeof(buf));
return ast_devstate_val(buf);
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=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/funcs/func_lock.c (original)
+++ branches/1.8/funcs/func_lock.c Thu May 10 11:47:17 2012
@@ -486,9 +486,11 @@
ast_custom_function_unregister(&trylock_function);
ast_custom_function_unregister(&unlock_function);
- pthread_cancel(broker_tid);
- pthread_kill(broker_tid, SIGURG);
- pthread_join(broker_tid, NULL);
+ if (broker_tid != AST_PTHREADT_NULL) {
+ pthread_cancel(broker_tid);
+ pthread_kill(broker_tid, SIGURG);
+ pthread_join(broker_tid, NULL);
+ }
AST_LIST_UNLOCK(&locklist);
@@ -500,7 +502,14 @@
int res = ast_custom_function_register(&lock_function);
res |= ast_custom_function_register(&trylock_function);
res |= ast_custom_function_register(&unlock_function);
- ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL);
+
+ if (ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL)) {
+ ast_log(LOG_ERROR, "Failed to start lock broker thread. Unloading func_lock module.\n");
+ broker_tid = AST_PTHREADT_NULL;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
return res;
}
Modified: branches/1.8/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/acl.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/acl.c (original)
+++ branches/1.8/main/acl.c Thu May 10 11:47:17 2012
@@ -533,7 +533,11 @@
if (ast_sockaddr_is_ipv6(addr)) {
if (ast_sockaddr_is_ipv4_mapped(addr)) {
/* IPv4 ACLs apply to IPv4-mapped addresses */
- ast_sockaddr_ipv4_mapped(addr, &mapped_addr);
+ if (!ast_sockaddr_ipv4_mapped(addr, &mapped_addr)) {
+ ast_log(LOG_ERROR, "%s provided to ast_sockaddr_ipv4_mapped could not be converted. That shouldn't be possible.\n",
+ ast_sockaddr_stringify(addr));
+ continue;
+ }
addr_to_use = &mapped_addr;
} else {
/* An IPv4 ACL does not apply to an IPv6 address */
Modified: branches/1.8/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/asterisk.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/asterisk.c (original)
+++ branches/1.8/main/asterisk.c Thu May 10 11:47:17 2012
@@ -1455,7 +1455,11 @@
ast_log(LOG_WARNING, "Unable to register network verboser?\n");
}
- ast_pthread_create_background(<hread, NULL, listener, NULL);
+ if (ast_pthread_create_background(<hread, NULL, listener, NULL)) {
+ ast_log(LOG_WARNING, "Unable to create listener thread.\n");
+ close(ast_socket);
+ return -1;
+ }
if (!ast_strlen_zero(ast_config_AST_CTL_OWNER)) {
struct passwd *pw;
@@ -3220,9 +3224,8 @@
sleep(120);
for (;;) {
- stat(canary_filename, &canary_stat);
now = ast_tvnow();
- if (now.tv_sec > canary_stat.st_mtime + 60) {
+ if (stat(canary_filename, &canary_stat) || now.tv_sec > canary_stat.st_mtime + 60) {
ast_log(LOG_WARNING,
"The canary is no more. He has ceased to be! "
"He's expired and gone to meet his maker! "
Modified: branches/1.8/main/db.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/db.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/db.c (original)
+++ branches/1.8/main/db.c Thu May 10 11:47:17 2012
@@ -778,7 +778,9 @@
return -1;
}
+ /* Ignore check_return warning from Coverity for dbinit below */
dbinit();
+
ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database));
ast_manager_register_xml("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget);
ast_manager_register_xml("DBPut", EVENT_FLAG_SYSTEM, manager_dbput);
Modified: branches/1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/features.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/features.c (original)
+++ branches/1.8/main/features.c Thu May 10 11:47:17 2012
@@ -1009,7 +1009,9 @@
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ast_pthread_create(&thread, &attr, bridge_call_thread, data);
+ if (ast_pthread_create(&thread, &attr, bridge_call_thread, data)) {
+ ast_log(LOG_WARNING, "Failed to create thread for parked call.\n");
+ }
pthread_attr_destroy(&attr);
memset(&sched, 0, sizeof(sched));
pthread_setschedparam(thread, SCHED_RR, &sched);
@@ -8149,7 +8151,9 @@
return res;
}
ast_cli_register_multiple(cli_features, ARRAY_LEN(cli_features));
- ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL);
+ if (ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL)) {
+ return -1;
+ }
ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL);
res = ast_register_application2(parkedcall, parked_call_exec, NULL, NULL, NULL);
if (!res)
Modified: branches/1.8/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/pbx.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/pbx.c (original)
+++ branches/1.8/main/pbx.c Thu May 10 11:47:17 2012
@@ -6541,8 +6541,10 @@
dpc->context_existence = 1;
- if (!c->pattern_tree)
+ if (!c->pattern_tree) {
+ /* Ignore check_return warning from Coverity for ast_exists_extension below */
ast_exists_extension(NULL, c->name, "s", 1, ""); /* do this to force the trie to built, if it is not already */
+ }
ast_rdlock_context(c);
Modified: branches/1.8/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/xmldoc.c?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/main/xmldoc.c (original)
+++ branches/1.8/main/xmldoc.c Thu May 10 11:47:17 2012
@@ -1715,7 +1715,11 @@
ast_xml_free_attr(paramname);
printed = 1;
}
- xmldoc_parse_para(node, internaltabs, "\n", buffer);
+ if (xmldoc_parse_para(node, internaltabs, "\n", buffer)) {
+ /* If anything ever goes in below this condition before the continue below,
+ * we should probably continue immediately. */
+ continue;
+ }
continue;
} else if ((xmldoc_parse_specialtags(node, internaltabs, "\n", buffer))) {
continue;
Modified: branches/1.8/res/ael/ael.flex
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/ael/ael.flex?view=diff&rev=366094&r1=366093&r2=366094
==============================================================================
--- branches/1.8/res/ael/ael.flex (original)
+++ branches/1.8/res/ael/ael.flex Thu May 10 11:47:17 2012
@@ -805,7 +805,9 @@
if (my_file)
free(my_file);
my_file = strdup(filename);
- stat(filename, &stats);
+ if (stat(filename, &stats)) {
+ ast_log(LOG_WARNING, "failed to populate stats from file '%s'\n", filename);
+ }
buffer = (char*)malloc(stats.st_size+2);
if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
@@ -875,7 +877,9 @@
} else {
char *buffer;
struct stat stats;
- stat(fnamebuf2, &stats);
+ if (stat(fnamebuf2, &stats)) {
+ ast_log(LOG_WARNING, "Failed to populate stats from file '%s'\n", fnamebuf2);
+ }
buffer = (char*)malloc(stats.st_size+1);
if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
More information about the asterisk-commits
mailing list