[asterisk-commits] dlee: branch dlee/record r397909 - in /team/dlee/record: ./ funcs/ main/ main...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 28 22:23:25 CDT 2013


Author: dlee
Date: Wed Aug 28 22:23:23 2013
New Revision: 397909

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397909
Log:
Merged revisions 397885-397902 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    team/dlee/record/   (props changed)
    team/dlee/record/funcs/func_cdr.c
    team/dlee/record/main/cdr.c
    team/dlee/record/main/stdtime/localtime.c

Propchange: team/dlee/record/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Aug 28 22:23:23 2013
@@ -1,1 +1,1 @@
-/branches/12:1-397878
+/branches/12:1-397908

Modified: team/dlee/record/funcs/func_cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/funcs/func_cdr.c?view=diff&rev=397909&r1=397908&r2=397909
==============================================================================
--- team/dlee/record/funcs/func_cdr.c (original)
+++ team/dlee/record/funcs/func_cdr.c Wed Aug 28 22:23:23 2013
@@ -20,7 +20,7 @@
  *
  * \brief  Call Detail Record related dialplan functions
  *
- * \author Anthony Minessale II 
+ * \author Anthony Minessale II
  *
  * \ingroup functions
  */
@@ -44,7 +44,7 @@
 	<function name="CDR" language="en_US">
 		<synopsis>
 			Gets or sets a CDR variable.
-		</synopsis>	
+		</synopsis>
 		<syntax>
 			<parameter name="name" required="true">
 				<para>CDR field name:</para>
@@ -204,15 +204,16 @@
 static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
 		    char *buf, size_t len)
 {
-	char format_buf[128];
 	char *value = NULL;
 	struct ast_flags flags = { 0 };
 	char tempbuf[512];
 	char *info;
 	AST_DECLARE_APP_ARGS(args,
-			     AST_APP_ARG(variable);
-			     AST_APP_ARG(options);
+		AST_APP_ARG(variable);
+		AST_APP_ARG(options);
 	);
+
+	buf[0] = '\0';/* Ensure the buffer is initialized. */
 
 	if (!chan) {
 		return -1;
@@ -237,31 +238,34 @@
 		}
 		ast_copy_string(tempbuf, value, sizeof(tempbuf));
 		ast_set_flag(&flags, OPT_UNPARSED);
-	}else if (ast_cdr_getvar(ast_channel_name(chan), args.variable, tempbuf, sizeof(tempbuf))) {
+	} else if (ast_cdr_getvar(ast_channel_name(chan), args.variable, tempbuf, sizeof(tempbuf))) {
 		return 0;
 	}
 
-	if (ast_test_flag(&flags, OPT_FLOAT) && (!strcasecmp("billsec", args.variable) || !strcasecmp("duration", args.variable))) {
+	if (ast_test_flag(&flags, OPT_FLOAT)
+		&& (!strcasecmp("billsec", args.variable) || !strcasecmp("duration", args.variable))) {
 		long ms;
 		double dtime;
+
 		if (sscanf(tempbuf, "%30ld", &ms) != 1) {
 			ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
-					args.variable, tempbuf, ast_channel_name(chan));
+				args.variable, tempbuf, ast_channel_name(chan));
 			return 0;
 		}
 		dtime = (double)(ms / 1000.0);
-		sprintf(tempbuf, "%lf", dtime);
+		snprintf(tempbuf, sizeof(tempbuf), "%lf", dtime);
 	} else if (!ast_test_flag(&flags, OPT_UNPARSED)) {
 		if (!strcasecmp("start", args.variable)
-				|| !strcasecmp("end", args.variable)
-				|| !strcasecmp("answer", args.variable)) {
+			|| !strcasecmp("end", args.variable)
+			|| !strcasecmp("answer", args.variable)) {
 			struct timeval fmt_time;
 			struct ast_tm tm;
 			/* tv_usec is suseconds_t, which could be int or long */
 			long int tv_usec;
+
 			if (sscanf(tempbuf, "%ld.%ld", &fmt_time.tv_sec, &tv_usec) != 2) {
 				ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
-						args.variable, tempbuf, ast_channel_name(chan));
+					args.variable, tempbuf, ast_channel_name(chan));
 				return 0;
 			}
 			fmt_time.tv_usec = tv_usec;
@@ -269,22 +273,22 @@
 			ast_strftime(tempbuf, sizeof(*tempbuf), "%Y-%m-%d %T", &tm);
 		} else if (!strcasecmp("disposition", args.variable)) {
 			int disposition;
+
 			if (sscanf(tempbuf, "%8d", &disposition) != 1) {
 				ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
-						args.variable, tempbuf, ast_channel_name(chan));
+					args.variable, tempbuf, ast_channel_name(chan));
 				return 0;
 			}
-			sprintf(format_buf, "%s", ast_cdr_disp2str(disposition));
-			strcpy(tempbuf, format_buf);
+			snprintf(tempbuf, sizeof(tempbuf), "%s", ast_cdr_disp2str(disposition));
 		} else if (!strcasecmp("amaflags", args.variable)) {
 			int amaflags;
+
 			if (sscanf(tempbuf, "%8d", &amaflags) != 1) {
 				ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
-						args.variable, tempbuf, ast_channel_name(chan));
+					args.variable, tempbuf, ast_channel_name(chan));
 				return 0;
 			}
-			sprintf(format_buf, "%s", ast_channel_amaflags2string(amaflags));
-			strcpy(tempbuf, format_buf);
+			snprintf(tempbuf, sizeof(tempbuf), "%s", ast_channel_amaflags2string(amaflags));
 		}
 	}
 
@@ -297,17 +301,19 @@
 {
 	struct ast_flags flags = { 0 };
 	AST_DECLARE_APP_ARGS(args,
-			     AST_APP_ARG(variable);
-			     AST_APP_ARG(options);
+		AST_APP_ARG(variable);
+		AST_APP_ARG(options);
 	);
 
-	if (ast_strlen_zero(parse) || !value || !chan)
+	if (ast_strlen_zero(parse) || !value || !chan) {
 		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	if (!ast_strlen_zero(args.options))
+	if (!ast_strlen_zero(args.options)) {
 		ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
+	}
 
 	if (!strcasecmp(args.variable, "accountcode")) {
 		ast_log(AST_LOG_WARNING, "Using the CDR function to set 'accountcode' is deprecated. Please use the CHANNEL function instead.\n");

Modified: team/dlee/record/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/cdr.c?view=diff&rev=397909&r1=397908&r2=397909
==============================================================================
--- team/dlee/record/main/cdr.c (original)
+++ team/dlee/record/main/cdr.c Wed Aug 28 22:23:23 2013
@@ -692,17 +692,25 @@
  */
 static int copy_variables(struct varshead *to_list, struct varshead *from_list)
 {
-	struct ast_var_t *variables, *newvariable = NULL;
-	const char *var, *val;
+	struct ast_var_t *variables;
+	struct ast_var_t *newvariable;
+	const char *var;
+	const char *val;
 	int x = 0;
 
 	AST_LIST_TRAVERSE(from_list, variables, entries) {
-		if (variables &&
-		    (var = ast_var_name(variables)) && (val = ast_var_value(variables)) &&
-		    !ast_strlen_zero(var) && !ast_strlen_zero(val) &&
-		    (newvariable = ast_var_assign(var, val))) {
+		var = ast_var_name(variables);
+		if (ast_strlen_zero(var)) {
+			continue;
+		}
+		val = ast_var_value(variables);
+		if (ast_strlen_zero(val)) {
+			continue;
+		}
+		newvariable = ast_var_assign(var, val);
+		if (newvariable) {
 			AST_LIST_INSERT_HEAD(to_list, newvariable, entries);
-			x++;
+			++x;
 		}
 	}
 
@@ -1114,7 +1122,7 @@
 			int found = 0;
 			struct ast_var_t *newvariable;
 			AST_LIST_TRAVERSE(&cdr_copy->varshead, it_copy_var, entries) {
-				if (!strcmp(ast_var_name(it_var), ast_var_name(it_copy_var))) {
+				if (!strcasecmp(ast_var_name(it_var), ast_var_name(it_copy_var))) {
 					found = 1;
 					break;
 				}
@@ -1313,7 +1321,7 @@
 {
 	RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);
 
-	ast_assert(strcmp(snapshot->name, cdr->party_a.snapshot->name) == 0);
+	ast_assert(strcasecmp(snapshot->name, cdr->party_a.snapshot->name) == 0);
 	cdr_object_swap_snapshot(&cdr->party_a, snapshot);
 
 	/* When Party A is originated to an application and the application exits, the stack
@@ -1359,7 +1367,7 @@
 {
 	char park_info[128];
 
-	ast_assert(!strcmp(parking_info->parkee->name, cdr->party_a.snapshot->name));
+	ast_assert(!strcasecmp(parking_info->parkee->name, cdr->party_a.snapshot->name));
 
 	/* Update Party A information regardless */
 	cdr->fn_table->process_party_a(cdr, parking_info->parkee);
@@ -1394,14 +1402,14 @@
 {
 	RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);
 
-	if (caller && !strcmp(cdr->party_a.snapshot->name, caller->name)) {
+	if (caller && !strcasecmp(cdr->party_a.snapshot->name, caller->name)) {
 		cdr_object_swap_snapshot(&cdr->party_a, caller);
 		CDR_DEBUG(mod_cfg, "%p - Updated Party A %s snapshot\n", cdr,
 				cdr->party_a.snapshot->name);
 		cdr_object_swap_snapshot(&cdr->party_b, peer);
 		CDR_DEBUG(mod_cfg, "%p - Updated Party B %s snapshot\n", cdr,
 				cdr->party_b.snapshot->name);
-	} else if (!strcmp(cdr->party_a.snapshot->name, peer->name)) {
+	} else if (!strcasecmp(cdr->party_a.snapshot->name, peer->name)) {
 		/* We're the entity being dialed, i.e., outbound origination */
 		cdr_object_swap_snapshot(&cdr->party_a, peer);
 		CDR_DEBUG(mod_cfg, "%p - Updated Party A %s snapshot\n", cdr,
@@ -1430,13 +1438,13 @@
 	struct cdr_object_snapshot *party_a;
 
 	/* Don't match on ourselves */
-	if (!strcmp(cdr->party_a.snapshot->name, cand_cdr->party_a.snapshot->name)) {
+	if (!strcasecmp(cdr->party_a.snapshot->name, cand_cdr->party_a.snapshot->name)) {
 		return 1;
 	}
 
 	/* Try the candidate CDR's Party A first */
 	party_a = cdr_object_pick_party_a(&cdr->party_a, &cand_cdr->party_a);
-	if (!strcmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
+	if (!strcasecmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
 		cdr_object_snapshot_copy(&cdr->party_b, &cand_cdr->party_a);
 		if (!cand_cdr->party_b.snapshot) {
 			/* We just stole them - finalize their CDR. Note that this won't
@@ -1449,11 +1457,12 @@
 	}
 
 	/* Try their Party B, unless it's us */
-	if (!cand_cdr->party_b.snapshot || !strcmp(cdr->party_a.snapshot->name, cand_cdr->party_b.snapshot->name)) {
+	if (!cand_cdr->party_b.snapshot
+		|| !strcasecmp(cdr->party_a.snapshot->name, cand_cdr->party_b.snapshot->name)) {
 		return 1;
 	}
 	party_a = cdr_object_pick_party_a(&cdr->party_a, &cand_cdr->party_b);
-	if (!strcmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
+	if (!strcasecmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
 		cdr_object_snapshot_copy(&cdr->party_b, &cand_cdr->party_b);
 		return 0;
 	}
@@ -1526,7 +1535,8 @@
 {
 	ast_assert(snapshot != NULL);
 
-	if (!cdr->party_b.snapshot || strcmp(cdr->party_b.snapshot->name, snapshot->name)) {
+	if (!cdr->party_b.snapshot
+		|| strcasecmp(cdr->party_b.snapshot->name, snapshot->name)) {
 		return;
 	}
 	cdr_object_swap_snapshot(&cdr->party_b, snapshot);
@@ -1583,11 +1593,11 @@
 	} else {
 		party_a = peer;
 	}
-	ast_assert(!strcmp(cdr->party_a.snapshot->name, party_a->name));
+	ast_assert(!strcasecmp(cdr->party_a.snapshot->name, party_a->name));
 	cdr_object_swap_snapshot(&cdr->party_a, party_a);
 
 	if (cdr->party_b.snapshot) {
-		if (strcmp(cdr->party_b.snapshot->name, peer->name)) {
+		if (strcasecmp(cdr->party_b.snapshot->name, peer->name)) {
 			/* Not the status for this CDR - defer back to the message router */
 			return 1;
 		}
@@ -1643,7 +1653,7 @@
 			}
 
 			/* Skip any records that aren't our Party B */
-			if (strcmp(cdr->party_b.snapshot->name, cand_cdr->party_a.snapshot->name)) {
+			if (strcasecmp(cdr->party_b.snapshot->name, cand_cdr->party_a.snapshot->name)) {
 				continue;
 			}
 			cdr_object_snapshot_copy(&cdr->party_b, &cand_cdr->party_a);
@@ -1716,7 +1726,8 @@
 
 static void bridge_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
 {
-	if (!cdr->party_b.snapshot || strcmp(cdr->party_b.snapshot->name, snapshot->name)) {
+	if (!cdr->party_b.snapshot
+		|| strcasecmp(cdr->party_b.snapshot->name, snapshot->name)) {
 		return;
 	}
 	cdr_object_swap_snapshot(&cdr->party_b, snapshot);
@@ -1732,9 +1743,9 @@
 	if (strcmp(cdr->bridge, bridge->uniqueid)) {
 		return 1;
 	}
-	if (strcmp(cdr->party_a.snapshot->name, channel->name)
-			&& cdr->party_b.snapshot
-			&& strcmp(cdr->party_b.snapshot->name, channel->name)) {
+	if (strcasecmp(cdr->party_a.snapshot->name, channel->name)
+		&& cdr->party_b.snapshot
+		&& strcasecmp(cdr->party_b.snapshot->name, channel->name)) {
 		return 1;
 	}
 	cdr_object_transition_state(cdr, &finalized_state_fn_table);
@@ -1746,7 +1757,7 @@
 
 static int parked_state_process_bridge_leave(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
 {
-	if (strcmp(cdr->party_a.snapshot->name, channel->name)) {
+	if (strcasecmp(cdr->party_a.snapshot->name, channel->name)) {
 		return 1;
 	}
 	cdr_object_transition_state(cdr, &finalized_state_fn_table);
@@ -1875,7 +1886,8 @@
 	struct ast_channel_snapshot *party_b = arg;
 	struct cdr_object *it_cdr;
 	for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
-		if (it_cdr->party_b.snapshot && !strcmp(it_cdr->party_b.snapshot->name, party_b->name)) {
+		if (it_cdr->party_b.snapshot
+			&& !strcasecmp(it_cdr->party_b.snapshot->name, party_b->name)) {
 			/* Don't transition to the finalized state - let the Party A do
 			 * that when its ready
 			 */
@@ -1894,7 +1906,8 @@
 		if (!it_cdr->fn_table->process_party_b) {
 			continue;
 		}
-		if (it_cdr->party_b.snapshot && !strcmp(it_cdr->party_b.snapshot->name, party_b->name)) {
+		if (it_cdr->party_b.snapshot
+			&& !strcasecmp(it_cdr->party_b.snapshot->name, party_b->name)) {
 			it_cdr->fn_table->process_party_b(it_cdr, party_b);
 		}
 	}
@@ -2067,7 +2080,7 @@
 		if (!it_cdr->party_b.snapshot) {
 			continue;
 		}
-		if (strcmp(it_cdr->party_b.snapshot->name, leave_data->channel->name)) {
+		if (strcasecmp(it_cdr->party_b.snapshot->name, leave_data->channel->name)) {
 			continue;
 		}
 		/* It is our Party B, in our bridge. Set the end time and let the handler
@@ -2354,23 +2367,24 @@
 	struct cdr_object_snapshot *party_a;
 
 	/* If the candidate is us or someone we've taken on, pass on by */
-	if (!strcmp(cdr->party_a.snapshot->name, bcand->candidate.snapshot->name)
-		|| (cdr->party_b.snapshot && !(strcmp(cdr->party_b.snapshot->name, bcand->candidate.snapshot->name)))) {
+	if (!strcasecmp(cdr->party_a.snapshot->name, bcand->candidate.snapshot->name)
+		|| (cdr->party_b.snapshot
+			&& !strcasecmp(cdr->party_b.snapshot->name, bcand->candidate.snapshot->name))) {
 		return 0;
 	}
 	party_a = cdr_object_pick_party_a(&cdr->party_a, &bcand->candidate);
 	/* We're party A - make a new CDR, append it to us, and set the candidate as
 	 * Party B */
-	if (!strcmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
+	if (!strcasecmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
 		bridge_candidate_add_to_cdr(cdr, cdr->bridge, &bcand->candidate);
 		return 0;
 	}
 
 	/* We're Party B. Check if the candidate is the CDR's Party A. If so, find out if we
 	 * can add ourselves directly as the Party B, or if we need a new CDR. */
-	if (!strcmp(bcand->cdr->party_a.snapshot->name, bcand->candidate.snapshot->name)) {
+	if (!strcasecmp(bcand->cdr->party_a.snapshot->name, bcand->candidate.snapshot->name)) {
 		if (bcand->cdr->party_b.snapshot
-				&& strcmp(bcand->cdr->party_b.snapshot->name, cdr->party_a.snapshot->name)) {
+			&& strcasecmp(bcand->cdr->party_b.snapshot->name, cdr->party_a.snapshot->name)) {
 			bridge_candidate_add_to_cdr(bcand->cdr, cdr->bridge, &cdr->party_a);
 		} else {
 			cdr_object_snapshot_copy(&bcand->cdr->party_b, &cdr->party_a);
@@ -2720,8 +2734,8 @@
 		return NULL;
 	}
 
-	memcpy(newcdr, cdr, sizeof(*newcdr));
-	memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
+	*newcdr = *cdr;
+	AST_LIST_HEAD_INIT_NOLOCK(&newcdr->varshead);
 	copy_variables(&newcdr->varshead, &cdr->varshead);
 	newcdr->next = NULL;
 
@@ -2731,19 +2745,18 @@
 static const char *cdr_format_var_internal(struct ast_cdr *cdr, const char *name)
 {
 	struct ast_var_t *variables;
-	struct varshead *headp = &cdr->varshead;
 
 	if (ast_strlen_zero(name)) {
 		return NULL;
 	}
 
-	AST_LIST_TRAVERSE(headp, variables, entries) {
+	AST_LIST_TRAVERSE(&cdr->varshead, variables, entries) {
 		if (!strcasecmp(name, ast_var_name(variables))) {
 			return ast_var_value(variables);
 		}
 	}
 
-	return '\0';
+	return NULL;
 }
 
 static void cdr_get_tv(struct timeval when, const char *fmt, char *buf, int bufsize)
@@ -2751,6 +2764,7 @@
 	if (fmt == NULL) {	/* raw mode */
 		snprintf(buf, bufsize, "%ld.%06ld", (long)when.tv_sec, (long)when.tv_usec);
 	} else {
+		buf[0] = '\0';/* Ensure the buffer is initialized. */
 		if (when.tv_sec) {
 			struct ast_tm tm;
 
@@ -2849,11 +2863,29 @@
 }
 
 /* Read Only CDR variables */
-static const char * const cdr_readonly_vars[] = { "clid", "src", "dst", "dcontext",
-	"channel", "dstchannel", "lastapp", "lastdata", "start", "answer", "end", "duration",
-	"billsec", "disposition", "amaflags", "accountcode", "uniqueid", "linkedid",
-	"userfield", "sequence", "total_duration", "total_billsec", "first_start",
-	"first_answer", NULL };
+static const char * const cdr_readonly_vars[] = {
+	"clid",
+	"src",
+	"dst",
+	"dcontext",
+	"channel",
+	"dstchannel",
+	"lastapp",
+	"lastdata",
+	"start",
+	"answer",
+	"end",
+	"duration",
+	"billsec",
+	"disposition",
+	"amaflags",
+	"accountcode",
+	"uniqueid",
+	"linkedid",
+	"userfield",
+	"sequence",
+	NULL
+};
 
 int ast_cdr_setvar(const char *channel_name, const char *name, const char *value)
 {
@@ -2880,12 +2912,14 @@
 		ao2_lock(cdr);
 		for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
 			struct varshead *headp = NULL;
+
 			if (it_cdr->fn_table == &finalized_state_fn_table) {
 				continue;
 			}
-			if (!strcmp(channel_name, it_cdr->party_a.snapshot->name)) {
+			if (!strcasecmp(channel_name, it_cdr->party_a.snapshot->name)) {
 				headp = &it_cdr->party_a.variables;
-			} else if (it_cdr->party_b.snapshot && !strcmp(channel_name, it_cdr->party_b.snapshot->name)) {
+			} else if (it_cdr->party_b.snapshot
+				&& !strcasecmp(channel_name, it_cdr->party_b.snapshot->name)) {
 				headp = &it_cdr->party_b.variables;
 			}
 			if (headp) {
@@ -3021,12 +3055,12 @@
 	int total = 0, x = 0, i;
 
 	if (!workspace) {
-		return 1;
+		return 0;
 	}
 
 	if (!cdr) {
 		ast_log(AST_LOG_ERROR, "Unable to find CDR for channel %s\n", channel_name);
-		return 1;
+		return 0;
 	}
 
 	ast_str_reset(*buf);
@@ -3050,9 +3084,11 @@
 		}
 
 		for (i = 0; cdr_readonly_vars[i]; i++) {
-			/* null out the workspace, because the cdr_get_tv() won't write anything if time is NULL, so you get old vals */
-			workspace[0] = 0;
-			cdr_object_format_property(it_cdr, cdr_readonly_vars[i], workspace, sizeof(workspace));
+			if (cdr_object_format_property(it_cdr, cdr_readonly_vars[i], workspace, sizeof(workspace))) {
+				/* Unhandled read-only CDR variable. */
+				ast_assert(0);
+				continue;
+			}
 
 			if (!ast_strlen_zero(workspace)
 				&& ast_str_append(buf, 0, "level %d: %s%c%s%c", x, cdr_readonly_vars[i], delim, workspace, sep) < 0) {
@@ -3120,7 +3156,7 @@
 			continue;
 		}
 		if (it_cdr->party_b.snapshot
-			&& !strcmp(it_cdr->party_b.snapshot->name, info->channel_name)) {
+			&& !strcasecmp(it_cdr->party_b.snapshot->name, info->channel_name)) {
 			strcpy(it_cdr->party_b.userfield, info->userfield);
 		}
 	}
@@ -3558,10 +3594,12 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	if (!strcmp(a->argv[3], "on") && !ast_test_flag(&mod_cfg->general->settings, CDR_DEBUG)) {
+	if (!strcasecmp(a->argv[3], "on")
+		&& !ast_test_flag(&mod_cfg->general->settings, CDR_DEBUG)) {
 		ast_set_flag(&mod_cfg->general->settings, CDR_DEBUG);
 		ast_cli(a->fd, "CDR debugging enabled\n");
-	} else if (!strcmp(a->argv[3], "off") && ast_test_flag(&mod_cfg->general->settings, CDR_DEBUG)) {
+	} else if (!strcasecmp(a->argv[3], "off")
+		&& ast_test_flag(&mod_cfg->general->settings, CDR_DEBUG)) {
 		ast_clear_flag(&mod_cfg->general->settings, CDR_DEBUG);
 		ast_cli(a->fd, "CDR debugging disabled\n");
 	}
@@ -3599,7 +3637,7 @@
 	struct ao2_iterator it_cdrs;
 	struct cdr_object *cdr;
 	char start_time_buffer[64];
-	char answer_time_buffer[64] = "\0";
+	char answer_time_buffer[64];
 	char end_time_buffer[64];
 
 #define TITLE_STRING "%-25.25s %-25.25s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8s %-8.8s\n"
@@ -3663,8 +3701,8 @@
 	struct cdr_object *it_cdr;
 	char clid[64];
 	char start_time_buffer[64];
-	char answer_time_buffer[64] = "\0";
-	char end_time_buffer[64] = "\0";
+	char answer_time_buffer[64];
+	char end_time_buffer[64];
 	const char *channel_name = a->argv[3];
 	RAII_VAR(struct cdr_object *, cdr, NULL, ao2_cleanup);
 

Modified: team/dlee/record/main/stdtime/localtime.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/stdtime/localtime.c?view=diff&rev=397909&r1=397908&r2=397909
==============================================================================
--- team/dlee/record/main/stdtime/localtime.c (original)
+++ team/dlee/record/main/stdtime/localtime.c Wed Aug 28 22:23:23 2013
@@ -2304,6 +2304,7 @@
 	long fraction;
 	const char *prevlocale;
 
+	buf[0] = '\0';/* Ensure the buffer is initialized. */
 	if (!format) {
 		return -1;
 	}




More information about the asterisk-commits mailing list