summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-08-18 12:04:21 (GMT)
committerThomas Haller <thaller@redhat.com>2023-08-18 12:07:19 (GMT)
commitf520471cb6e2340309028e0400b8186db3635e0f (patch)
tree032e80ca1c7067489fbe0c60f315f0a0705b4da7 /lib
parentbe5add72bd0c86053561882efda33f40b804e435 (diff)
downloadlibnl-f520471cb6e2340309028e0400b8186db3635e0f.zip
libnl-f520471cb6e2340309028e0400b8186db3635e0f.tar.gz
libnl-f520471cb6e2340309028e0400b8186db3635e0f.tar.bz2
lib/xfrm: use thread-safe gmtime_r() instead of gmtime()
Diffstat (limited to 'lib')
-rw-r--r--lib/xfrm/ae.c5
-rw-r--r--lib/xfrm/sa.c5
-rw-r--r--lib/xfrm/sp.c5
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/xfrm/ae.c b/lib/xfrm/ae.c
index fbd669f..4f56690 100644
--- a/lib/xfrm/ae.c
+++ b/lib/xfrm/ae.c
@@ -335,6 +335,7 @@ static void xfrm_ae_dump_line(struct nl_object *a, struct nl_dump_params *p)
char flags[128], buf[128];
time_t add_time, use_time;
struct tm *add_time_tm, *use_time_tm;
+ struct tm tm_buf;
nl_dump_line(p, "src %s dst %s \n", nl_addr2str(ae->saddr, src, sizeof(src)),
nl_addr2str(ae->sa_id.daddr, dst, sizeof(dst)));
@@ -354,7 +355,7 @@ static void xfrm_ae_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (ae->lifetime_cur.add_time != 0)
{
add_time = ae->lifetime_cur.add_time;
- add_time_tm = gmtime (&add_time);
+ add_time_tm = gmtime_r (&add_time, &tm_buf);
strftime (flags, 128, "%Y-%m-%d %H-%M-%S", add_time_tm);
}
else
@@ -365,7 +366,7 @@ static void xfrm_ae_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (ae->lifetime_cur.use_time != 0)
{
use_time = ae->lifetime_cur.use_time;
- use_time_tm = gmtime (&use_time);
+ use_time_tm = gmtime_r (&use_time, &tm_buf);
strftime (buf, 128, "%Y-%m-%d %H-%M-%S", use_time_tm);
}
else
diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c
index 0c1f778..44faa89 100644
--- a/lib/xfrm/sa.c
+++ b/lib/xfrm/sa.c
@@ -502,6 +502,7 @@ static void xfrm_sa_dump_line(struct nl_object *a, struct nl_dump_params *p)
char flags[128], mode[128];
time_t add_time, use_time;
struct tm *add_time_tm, *use_time_tm;
+ struct tm tm_buf;
nl_dump_line(p, "src %s dst %s family: %s\n", nl_addr2str(sa->saddr, src, sizeof(src)),
nl_addr2str(sa->id.daddr, dst, sizeof(dst)),
@@ -554,7 +555,7 @@ static void xfrm_sa_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (sa->curlft.add_time != 0)
{
add_time = sa->curlft.add_time;
- add_time_tm = gmtime (&add_time);
+ add_time_tm = gmtime_r (&add_time, &tm_buf);
strftime (flags, 128, "%Y-%m-%d %H-%M-%S", add_time_tm);
}
else
@@ -565,7 +566,7 @@ static void xfrm_sa_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (sa->curlft.use_time != 0)
{
use_time = sa->curlft.use_time;
- use_time_tm = gmtime (&use_time);
+ use_time_tm = gmtime_r (&use_time, &tm_buf);
strftime (mode, 128, "%Y-%m-%d %H-%M-%S", use_time_tm);
}
else
diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c
index 0863b12..cf10651 100644
--- a/lib/xfrm/sp.c
+++ b/lib/xfrm/sp.c
@@ -357,6 +357,7 @@ static void xfrm_sp_dump_line(struct nl_object *a, struct nl_dump_params *p)
char dst[INET6_ADDRSTRLEN+5], src[INET6_ADDRSTRLEN+5];
time_t add_time, use_time;
struct tm *add_time_tm, *use_time_tm;
+ struct tm tm_buf;
nl_addr2str(xfrmnl_sel_get_saddr (sp->sel), src, sizeof(src));
nl_addr2str (xfrmnl_sel_get_daddr (sp->sel), dst, sizeof (dst));
@@ -417,7 +418,7 @@ static void xfrm_sp_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (sp->curlft.add_time != 0)
{
add_time = sp->curlft.add_time;
- add_time_tm = gmtime (&add_time);
+ add_time_tm = gmtime_r (&add_time, &tm_buf);
strftime (dst, INET6_ADDRSTRLEN+5, "%Y-%m-%d %H-%M-%S", add_time_tm);
}
else
@@ -428,7 +429,7 @@ static void xfrm_sp_dump_line(struct nl_object *a, struct nl_dump_params *p)
if (sp->curlft.use_time != 0)
{
use_time = sp->curlft.use_time;
- use_time_tm = gmtime (&use_time);
+ use_time_tm = gmtime_r (&use_time, &tm_buf);
strftime (src, INET6_ADDRSTRLEN+5, "%Y-%m-%d %H-%M-%S", use_time_tm);
}
else