108 lines
3.9 KiB
Diff
108 lines
3.9 KiB
Diff
From f520471cb6e2340309028e0400b8186db3635e0f Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Fri, 18 Aug 2023 14:04:21 +0200
|
|
Subject: [PATCH] lib/xfrm: use thread-safe gmtime_r() instead of gmtime()
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/thom311/libnl/commit/f520471cb6e2340309028e0400b8186db3635e0f
|
|
|
|
---
|
|
lib/xfrm/ae.c | 5 +++--
|
|
lib/xfrm/sa.c | 5 +++--
|
|
lib/xfrm/sp.c | 5 +++--
|
|
3 files changed, 9 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/lib/xfrm/ae.c b/lib/xfrm/ae.c
|
|
index a56cd87..522cef0 100644
|
|
--- a/lib/xfrm/ae.c
|
|
+++ b/lib/xfrm/ae.c
|
|
@@ -299,6 +299,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)));
|
|
@@ -317,7 +318,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
|
|
@@ -328,7 +329,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 6b3daf4..63a13ba 100644
|
|
--- a/lib/xfrm/sa.c
|
|
+++ b/lib/xfrm/sa.c
|
|
@@ -411,6 +411,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)),
|
|
@@ -454,7 +455,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
|
|
@@ -465,7 +466,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 3943469..1984099 100644
|
|
--- a/lib/xfrm/sp.c
|
|
+++ b/lib/xfrm/sp.c
|
|
@@ -325,6 +325,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));
|
|
@@ -375,7 +376,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
|
|
@@ -386,7 +387,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
|
|
--
|
|
2.33.0
|
|
|