[Freeswitch-svn] [commit] r3306 - freeswitch/trunk/src
Freeswitch SVN
mikej at freeswitch.org
Fri Nov 10 11:30:03 EST 2006
Author: mikej
Date: Fri Nov 10 11:30:02 2006
New Revision: 3306
Modified:
freeswitch/trunk/src/switch_log.c
freeswitch/trunk/src/switch_utils.c
Log:
make logger handle a bit more bad input.
Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c (original)
+++ freeswitch/trunk/src/switch_log.c Fri Nov 10 11:30:02 2006
@@ -169,7 +169,8 @@
int ret = 0;
va_list ap;
FILE *handle;
- char *filep = switch_cut_path(file);
+ char *filep = (file ? switch_cut_path(file): "");
+ const char *funcp = (func ? func : "");
char *content = NULL;
switch_time_t now = switch_time_now();
uint32_t len;
@@ -186,9 +187,9 @@
switch_time_exp_lt(&tm, now);
switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
- len = (uint32_t)(strlen(extra_fmt) + strlen(date) + strlen(filep) + 32 + strlen(func) + strlen(fmt));
+ len = (uint32_t)(strlen(extra_fmt) + strlen(date) + strlen(filep) + 32 + strlen(funcp) + strlen(fmt));
new_fmt = malloc(len+1);
- snprintf(new_fmt, len, extra_fmt, date, LEVELS[level], filep, line, func, 128, fmt);
+ snprintf(new_fmt, len, extra_fmt, date, LEVELS[level], filep, line, funcp, 128, fmt);
fmt = new_fmt;
}
@@ -216,7 +217,7 @@
if (switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", funcp);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Level", "%d", (int)level);
switch_event_fire(&event);
@@ -231,7 +232,7 @@
if ((node = malloc(sizeof(*node)))) {
node->data = data;
node->file = strdup(filep);
- node->func = strdup(func);
+ node->func = strdup(funcp);
node->line = line;
node->level = level;
node->content = content;
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Fri Nov 10 11:30:02 2006
@@ -167,13 +167,17 @@
char delims[] = "/\\";
char *i;
- for (i = delims; *i; i++) {
- p = in;
- while ((p = strchr(p, *i)) != 0) {
- ret = ++p;
+ if (in) {
+ for (i = delims; *i; i++) {
+ p = in;
+ while ((p = strchr(p, *i)) != 0) {
+ ret = ++p;
+ }
}
+ return ret;
+ } else {
+ return NULL;
}
- return ret;
}
SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
More information about the Freeswitch-svn
mailing list