[asterisk-commits] jrose: trunk r366126 - in /trunk: ./ apps/ channels/ funcs/ main/ res/ael/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 10 13:35:25 CDT 2012


Author: jrose
Date: Thu May 10 13:35:14 2012
New Revision: 366126

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366126
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/
........

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

Merged revisions 366106 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c
    trunk/apps/app_voicemail.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/channels/iax2-provision.c
    trunk/channels/sig_analog.c
    trunk/funcs/func_devstate.c
    trunk/funcs/func_lock.c
    trunk/main/acl.c
    trunk/main/asterisk.c
    trunk/main/features.c
    trunk/main/pbx.c
    trunk/main/xmldoc.c
    trunk/res/ael/ael.flex

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu May 10 13:35:14 2012
@@ -4946,7 +4946,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, ast_channel_name(peer));
+					}
 				}
 				if (!res2 && qe->parent->reportholdtime) {
 					if (!play_file(peer, qe->parent->sound_reporthold)) {
@@ -4957,11 +4959,15 @@
 						holdtimesecs = abs((now - qe->start) % 60);
 						if (holdtime > 0) {
 							ast_say_number(peer, holdtime, AST_DIGIT_ANY, ast_channel_language(peer), 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, ast_channel_name(peer));
+							}
 						}
 						if (holdtimesecs > 1) {
 							ast_say_number(peer, holdtimesecs, AST_DIGIT_ANY, ast_channel_language(peer), 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, ast_channel_name(peer));
+							}
 						}
 					}
 				}

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu May 10 13:35:14 2012
@@ -6983,7 +6983,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
 
@@ -9561,7 +9564,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) {
@@ -11762,6 +11768,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);
@@ -11775,7 +11782,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: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu May 10 13:35:14 2012
@@ -4382,11 +4382,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, &regseconds, 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")) {
@@ -11653,6 +11655,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);
 }
 
@@ -12234,7 +12237,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: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu May 10 13:35:14 2012
@@ -16384,7 +16384,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);
@@ -16733,6 +16735,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;
@@ -18682,7 +18685,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 && ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
 		duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);

Modified: trunk/channels/iax2-provision.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/iax2-provision.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/channels/iax2-provision.c (original)
+++ trunk/channels/iax2-provision.c Thu May 10 13:35:14 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: trunk/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Thu May 10 13:35:14 2012
@@ -2744,7 +2744,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: trunk/funcs/func_devstate.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_devstate.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/funcs/func_devstate.c (original)
+++ trunk/funcs/func_devstate.c Thu May 10 13:35:14 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: trunk/funcs/func_lock.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_lock.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/funcs/func_lock.c (original)
+++ trunk/funcs/func_lock.c Thu May 10 13:35:14 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: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Thu May 10 13:35:14 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: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Thu May 10 13:35:14 2012
@@ -1468,7 +1468,11 @@
 		ast_log(LOG_WARNING, "Unable to register network verboser?\n");
 	}
 
-	ast_pthread_create_background(&lthread, NULL, listener, NULL);
+	if (ast_pthread_create_background(&lthread, 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;
@@ -3345,9 +3349,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: trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Thu May 10 13:35:14 2012
@@ -8658,7 +8658,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: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Thu May 10 13:35:14 2012
@@ -6709,8 +6709,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: trunk/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/xmldoc.c?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/main/xmldoc.c (original)
+++ trunk/main/xmldoc.c Thu May 10 13:35:14 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: trunk/res/ael/ael.flex
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ael/ael.flex?view=diff&rev=366126&r1=366125&r2=366126
==============================================================================
--- trunk/res/ael/ael.flex (original)
+++ trunk/res/ael/ael.flex Thu May 10 13:35:14 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