summaryrefslogtreecommitdiff
path: root/plugins/audit_json
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@sudo.ws>2021-09-17 10:55:06 -0600
committerTodd C. Miller <Todd.Miller@sudo.ws>2021-09-17 10:55:06 -0600
commit74273bae159e9f6ac79bee2a0c7438934993da93 (patch)
tree143fe88fa424aea363e80dfc718f88e69a12f5dc /plugins/audit_json
parenteb87b9312d8e0a1dc746cdcb598e2be5cc1c3ed3 (diff)
downloadsudo-74273bae159e9f6ac79bee2a0c7438934993da93.tar.gz
Use gmtime_r() and localtime_r() instead of gmtime() and localtime().
Diffstat (limited to 'plugins/audit_json')
-rw-r--r--plugins/audit_json/audit_json.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/audit_json/audit_json.c b/plugins/audit_json/audit_json.c
index 74a2eb926..9e57a562c 100644
--- a/plugins/audit_json/audit_json.c
+++ b/plugins/audit_json/audit_json.c
@@ -341,10 +341,10 @@ add_timestamp(struct json_container *json, struct timespec *ts)
struct json_value json_value;
time_t secs = ts->tv_sec;
char timebuf[1024];
- struct tm *tm;
+ struct tm gmt;
debug_decl(add_timestamp, SUDO_DEBUG_PLUGIN);
- if ((tm = gmtime(&secs)) == NULL)
+ if (gmtime_r(&secs, &gmt) == NULL)
debug_return_bool(false);
sudo_json_open_object(json, "timestamp");
@@ -357,12 +357,12 @@ add_timestamp(struct json_container *json, struct timespec *ts)
json_value.u.number = ts->tv_nsec;
sudo_json_add_value(json, "nanoseconds", &json_value);
- strftime(timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", tm);
+ strftime(timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", &gmt);
json_value.type = JSON_STRING;
json_value.u.string = timebuf;
sudo_json_add_value(json, "iso8601", &json_value);
- strftime(timebuf, sizeof(timebuf), "%a %b %e %H:%M:%S %Z %Y", tm);
+ strftime(timebuf, sizeof(timebuf), "%a %b %e %H:%M:%S %Z %Y", &gmt);
json_value.type = JSON_STRING;
json_value.u.string = timebuf;
sudo_json_add_value(json, "localtime", &json_value);