Use gmtime_r() and localtime_r() instead of gmtime() and localtime().
This commit is contained in:
@@ -117,7 +117,7 @@ static int
|
||||
sample_approval_check(char * const command_info[], char * const run_argv[],
|
||||
char * const run_envp[], const char **errstr)
|
||||
{
|
||||
struct tm *tm;
|
||||
struct tm tm;
|
||||
time_t now;
|
||||
int ret = 0;
|
||||
debug_decl(sample_approval_check, SUDO_DEBUG_PLUGIN);
|
||||
@@ -126,14 +126,14 @@ sample_approval_check(char * const command_info[], char * const run_argv[],
|
||||
* Only approve requests that are within business hours,
|
||||
* which are 9am - 5pm local time. Does not check holidays.
|
||||
*/
|
||||
if (time(&now) == -1 || (tm = localtime(&now)) == NULL)
|
||||
if (time(&now) == -1 || localtime_r(&now, &tm) == NULL)
|
||||
goto done;
|
||||
if (tm->tm_wday < 1 || tm->tm_wday > 5) {
|
||||
if (tm.tm_wday < 1 || tm.tm_wday > 5) {
|
||||
/* bad weekday */
|
||||
goto done;
|
||||
}
|
||||
if (tm->tm_hour < 9 || tm->tm_hour > 17 ||
|
||||
(tm->tm_hour == 17 && tm->tm_min > 0)) {
|
||||
if (tm.tm_hour < 9 || tm.tm_hour > 17 ||
|
||||
(tm.tm_hour == 17 && tm.tm_min > 0)) {
|
||||
/* bad hour */
|
||||
goto done;
|
||||
}
|
||||
|
Reference in New Issue
Block a user