summaryrefslogtreecommitdiff
path: root/clients/cli/connections.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-05-06 22:33:52 +0200
committerThomas Haller <thaller@redhat.com>2020-05-07 13:58:08 +0200
commit6f0dadabd750e28a3617d798f1d9325d0f0c4b79 (patch)
treeca5ab5e58b2a97249caa6bce2fca972f68f5d321 /clients/cli/connections.c
parent53b229770199e197d6482a96710650a55609afe1 (diff)
downloadNetworkManager-6f0dadabd750e28a3617d798f1d9325d0f0c4b79.tar.gz
cli: avoid non-thread-safe localtime() function in nmcli
Static analysis tools flag the use of localtime() because it is not thread safe. Of course, that was no problem here, but avoiding the warning is simple. Also, if we allocate 128 bytes, let strftime use it.
Diffstat (limited to 'clients/cli/connections.c')
-rw-r--r--clients/cli/connections.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 0e4a95e68a..ec0b9200a7 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -541,6 +541,8 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
if (info->info_type == NMC_GENERIC_INFO_TYPE_CON_SHOW_TIMESTAMP)
return (*out_to_free = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp));
else {
+ struct tm localtime_result;
+
if (!timestamp) {
if (get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
return _("never");
@@ -548,7 +550,7 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
}
timestamp_real = timestamp;
s_mut = g_malloc0 (128);
- strftime (s_mut, 64, "%c", localtime (&timestamp_real));
+ strftime (s_mut, 127, "%c", localtime_r (&timestamp_real, &localtime_result));
return (*out_to_free = s_mut);
}
}