From: Jeff Lenk Date: Wed, 13 Jul 2011 13:43:35 +0000 (-0500) Subject: FS-3417 --resolve Heap corruption in strftime_api_function -thanks X-Git-Tag: v1.2-rc1~108^2^2~23^2~8^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=707bd05b7c83be5ba1d4dfb18bbb815d21f31927;p=thirdparty%2Ffreeswitch.git FS-3417 --resolve Heap corruption in strftime_api_function -thanks --- diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 990a7ca956..d62db97e13 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1352,27 +1352,28 @@ SWITCH_STANDARD_API(strftime_api_function) switch_time_exp_t tm; char date[80] = ""; switch_time_t thetime; - char *p; + char *p, *q = NULL; char *mycmd = NULL; if (!zstr(cmd)) { mycmd = strdup(cmd); + q = mycmd; } - if (!zstr(mycmd) && (p = strchr(mycmd, '|'))) { + if (!zstr(q) && (p = strchr(q, '|'))) { *p++ = '\0'; - thetime = switch_time_make(atol(mycmd), 0); - mycmd = p + 1; + thetime = switch_time_make(atol(q), 0); + q = p + 1; } else { thetime = switch_micro_time_now(); } switch_time_exp_lt(&tm, thetime); - if (zstr(mycmd)) { + if (zstr(q)) { switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); } else { - switch_strftime(date, &retsize, sizeof(date), mycmd, &tm); + switch_strftime(date, &retsize, sizeof(date), q, &tm); } stream->write_function(stream, "%s", date); switch_safe_free(mycmd);