validate strftime format string input (when necessary)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9985 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2008-10-12 21:51:51 +00:00
parent a21b5ed2ad
commit 1f47ff15b3
14 changed files with 92 additions and 28 deletions
@@ -1022,7 +1022,11 @@ SWITCH_STANDARD_API(strftime_api_function)
thetime = switch_timestamp_now();
}
switch_time_exp_lt(&tm, thetime);
switch_strftime(date, &retsize, sizeof(date), switch_strlen_zero(cmd) ? "%Y-%m-%d %T" : cmd, &tm);
if (switch_strlen_zero(cmd)) {
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
} else {
switch_strftime(date, &retsize, sizeof(date), cmd, &tm);
}
stream->write_function(stream, "%s", date);
return SWITCH_STATUS_SUCCESS;
+5 -5
View File
@@ -520,7 +520,7 @@ SWITCH_STANDARD_APP(fifo_function)
ts = switch_timestamp_now();
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING");
switch_channel_set_variable(channel, "fifo_timestamp", date);
@@ -613,7 +613,7 @@ SWITCH_STANDARD_APP(fifo_function)
} else {
ts = switch_timestamp_now();
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED");
switch_channel_set_variable(channel, "fifo_timestamp", date);
@@ -709,7 +709,7 @@ SWITCH_STANDARD_APP(fifo_function)
ts = switch_timestamp_now();
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING");
switch_channel_set_variable(channel, "fifo_timestamp", date);
@@ -883,7 +883,7 @@ SWITCH_STANDARD_APP(fifo_function)
ts = switch_timestamp_now();
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "TALKING");
switch_channel_set_variable(channel, "fifo_target", uuid);
switch_channel_set_variable(channel, "fifo_timestamp", date);
@@ -910,7 +910,7 @@ SWITCH_STANDARD_APP(fifo_function)
ts = switch_timestamp_now();
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING");
switch_channel_set_variable(channel, "fifo_timestamp", date);
+1 -1
View File
@@ -480,7 +480,7 @@ SWITCH_STANDARD_APP(rss_function)
char dtmf[5] = "";
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%I:%M %p", &tm);
switch_snprintf(buf, sizeof(buf),
@@ -2728,7 +2728,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
free(dbuf);
switch_time_exp_lt(&tm, ts);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "RECORD_DATE", date);
switch_channel_set_variable(channel, "RECORD_SOFTWARE", "FreeSWITCH");
switch_channel_set_variable(channel, "RECORD_TITLE", profile->record_title);
@@ -3176,13 +3176,13 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames)
if (l_created) {
switch_time_exp_lt(&tm, l_created);
switch_strftime(create_date, &retsize, sizeof(create_date), fmt, &tm);
switch_strftime(rss_date, &retsize, sizeof(create_date), "%D %T", &tm);
switch_strftime_nocheck(create_date, &retsize, sizeof(create_date), fmt, &tm);
switch_strftime_nocheck(rss_date, &retsize, sizeof(create_date), "%D %T", &tm);
}
if (l_read) {
switch_time_exp_lt(&tm, l_read);
switch_strftime(read_date, &retsize, sizeof(read_date), fmt, &tm);
switch_strftime_nocheck(read_date, &retsize, sizeof(read_date), fmt, &tm);
}
switch_snprintf(heard, sizeof(heard), *read_date == '\0' ? "never" : read_date);
@@ -3256,13 +3256,13 @@ static int rss_callback(void *pArg, int argc, char **argv, char **columnNames)
if (l_created) {
switch_time_exp_lt(&tm, l_created);
switch_strftime(create_date, &retsize, sizeof(create_date), fmt, &tm);
switch_strftime(rss_date, &retsize, sizeof(create_date), fmt, &tm);
switch_strftime_nocheck(create_date, &retsize, sizeof(create_date), fmt, &tm);
switch_strftime_nocheck(rss_date, &retsize, sizeof(create_date), fmt, &tm);
}
if (l_read) {
switch_time_exp_lt(&tm, l_read);
switch_strftime(read_date, &retsize, sizeof(read_date), fmt, &tm);
switch_strftime_nocheck(read_date, &retsize, sizeof(read_date), fmt, &tm);
}
holder->x_item = switch_xml_add_child_d(holder->x_channel, "item", holder->items++);
+1 -1
View File
@@ -1251,7 +1251,7 @@ static int show_reg_callback(void *pArg, int argc, char **argv, char **columnNam
switch_size_t retsize;
switch_time_exp_lt(&tm, switch_time_from_sec(etime));
switch_strftime(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
}
cb->stream->write_function(cb->stream,
@@ -100,7 +100,7 @@ static void do_rotate(cdr_fd_t *fd)
if (globals.rotate) {
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
len = strlen(fd->path) + strlen(date) + 2;
p = switch_mprintf("%s.%s", fd->path, date);
+1 -1
View File
@@ -125,7 +125,7 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile)
switch_mutex_lock(globals.mutex);
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
profile->log_size = 0;