mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
Avoid using undefined memory in switch_fulldate_cmp
The `switch_split_date` and `switch_split_time` functions only set as many variables as they believe exist values in the input string. Since we didn't have defaults assigned we would read undefined stack memory if the input string didn't contain e.g. an hour. With this commit, we use 1970 if no year is present, January if no month is present, the first day of the month if none is given, and zero for each of a missing hour, minute, or second.
This commit is contained in:
parent
bf42dd65f1
commit
b5a87aea7f
@ -3005,8 +3005,8 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
||||
if ((sTime=strchr(sStart, ' '))) {
|
||||
switch_time_t tsStart;
|
||||
struct tm tmTmp;
|
||||
int year, month, day;
|
||||
int hour, min, sec;
|
||||
int year = 1970, month = 1, day = 1;
|
||||
int hour = 0, min = 0, sec = 0;
|
||||
*sTime++ = '\0';
|
||||
|
||||
memset(&tmTmp, 0, sizeof(tmTmp));
|
||||
@ -3026,8 +3026,8 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
||||
if ((sTime=strchr(sEnd, ' '))) {
|
||||
switch_time_t tsEnd;
|
||||
struct tm tmTmp;
|
||||
int year, month, day;
|
||||
int hour, min, sec;
|
||||
int year = 1970, month = 1, day = 1;
|
||||
int hour = 0, min = 0, sec = 0;
|
||||
*sTime++ = '\0';
|
||||
|
||||
memset(&tmTmp, 0, sizeof(tmTmp));
|
||||
|
Loading…
x
Reference in New Issue
Block a user