systime-fix: Replace asctime() with thread-safe asctime_r()
authorTobias Brunner <tobias@strongswan.org>
Tue, 28 Jan 2020 13:55:25 +0000 (14:55 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 28 Jan 2020 14:32:43 +0000 (15:32 +0100)
According to the man page, the buffer should have room for at least
26 characters.

src/libcharon/plugins/systime_fix/systime_fix_plugin.c

index 3209c91..41ff083 100644 (file)
@@ -205,7 +205,7 @@ static bool load_validator(private_systime_fix_plugin_t *this)
        struct tm tm = {
                .tm_mday = 1,
        };
-       char *str, *fmt;
+       char *str, *fmt, buf[32];
 
        fmt = lib->settings->get_str(lib->settings,
                        "%s.plugins.%s.threshold_format", "%Y", lib->ns, get_name(this));
@@ -235,7 +235,8 @@ static bool load_validator(private_systime_fix_plugin_t *this)
                return FALSE;
        }
 
-       DBG1(DBG_CFG, "enabling %s, threshold: %s", get_name(this), asctime(&tm));
+       DBG1(DBG_CFG, "enabling %s, threshold: %s", get_name(this),
+                asctime_r(&tm, buf));
        this->validator = systime_fix_validator_create(this->threshold);
        return TRUE;
 }