]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: replace ctime with ctime_r
authorMark Stapp <mjs@labn.net>
Tue, 19 Sep 2023 17:15:21 +0000 (13:15 -0400)
committerMark Stapp <mjs@labn.net>
Tue, 19 Sep 2023 20:25:01 +0000 (16:25 -0400)
No ctime, use ctime_r.

Signed-off-by: Mark Stapp <mjs@labn.net>
bgpd/bgp_btoa.c
bgpd/bgp_labelpool.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_nexthop.c
bgpd/bgp_route.c
bgpd/bgp_updgrp.c
bgpd/bgpd.h

index fc3363b098e705402a2060134b8413d6dcd1a7ca..8e27d9769f81295d6ceda550bdd1a78a016980a2 100644 (file)
@@ -120,6 +120,7 @@ int main(int argc, char **argv)
        struct in_addr dip;
        uint16_t viewno, seq_num;
        struct prefix_ipv4 p;
+       char tbuf[32];
 
        s = stream_new(10000);
 
@@ -155,7 +156,7 @@ int main(int argc, char **argv)
                subtype = stream_getw(s);
                len = stream_getl(s);
 
-               printf("TIME: %s", ctime(&now));
+               printf("TIME: %s", ctime_r(&now, tbuf));
 
                /* printf ("TYPE: %d/%d\n", type, subtype); */
 
@@ -239,7 +240,8 @@ int main(int argc, char **argv)
                                source_as = stream_getw(s);
 
                                printf("FROM: %pI4 AS%d\n", &peer, source_as);
-                               printf("ORIGINATED: %s", ctime(&originated));
+                               printf("ORIGINATED: %s", ctime_r(&originated,
+                                                                tbuf));
 
                                attrlen = stream_getw(s);
                                printf("ATTRLEN: %d\n", attrlen);
index dc032660ceebae9be904ed8cfdcc1e63b29da2d3..883338610c64711e7dbf2116d6aa0d9197dc94f6 100644 (file)
@@ -1131,7 +1131,7 @@ static void show_bgp_nexthop_label_afi(struct vty *vty, afi_t afi,
                                ifindex2ifname(iter->nh->ifindex,
                                               iter->nh->vrf_id));
                tbuf = time(NULL) - (monotime(NULL) - iter->last_update);
-               vty_out(vty, "  Last update: %s", ctime(&tbuf));
+               vty_out(vty, "  Last update: %s", ctime_r(&tbuf, buf));
                if (!detail)
                        continue;
                vty_out(vty, "  Paths:\n");
index 9b5d56863619720685e725c2abba0024328672b0..82120e7b83cc558fdba7d995371a084f8f9a2a81 100644 (file)
@@ -4204,6 +4204,7 @@ static void show_bgp_mplsvpn_nh_label_bind_internal(struct vty *vty,
        struct bgp *bgp_path;
        struct bgp_table *table;
        time_t tbuf;
+       char buf[32];
 
        vty_out(vty, "Current BGP mpls-vpn nexthop label bind cache, %s\n",
                bgp->name_pretty);
@@ -4221,7 +4222,7 @@ static void show_bgp_mplsvpn_nh_label_bind_internal(struct vty *vty,
                                ifindex2ifname(iter->nh->ifindex,
                                               iter->nh->vrf_id));
                tbuf = time(NULL) - (monotime(NULL) - iter->last_update);
-               vty_out(vty, "  Last update: %s", ctime(&tbuf));
+               vty_out(vty, "  Last update: %s", ctime_r(&tbuf, buf));
                if (!detail)
                        continue;
                vty_out(vty, "  Paths:\n");
index 7f1a6e73e171e4de0de615bb7117cbe613fbb914..d12dc22330133eb196f6e641f86fd128d00d17f0 100644 (file)
@@ -972,6 +972,7 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
 {
        char buf[PREFIX2STR_BUFFER];
        time_t tbuf;
+       char timebuf[32];
        struct peer *peer;
        json_object *json_last_update = NULL;
        json_object *json_nexthop = NULL;
@@ -1070,14 +1071,14 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
                        json_last_update = json_object_new_object();
                        json_object_int_add(json_last_update, "epoch", tbuf);
                        json_object_string_add(json_last_update, "string",
-                                              ctime(&tbuf));
+                                              ctime_r(&tbuf, timebuf));
                        json_object_object_add(json_nexthop, "lastUpdate",
                                               json_last_update);
                } else {
                        json_object_int_add(json_nexthop, "lastUpdate", tbuf);
                }
        } else {
-               vty_out(vty, "  Last update: %s", ctime(&tbuf));
+               vty_out(vty, "  Last update: %s", ctime_r(&tbuf, timebuf));
        }
 
        /* show paths dependent on nexthop, if needed. */
index df3397af999ec562aa438f179128e1db073a657a..d9881e730face33ab599c7b1b9dc94788047890e 100644 (file)
@@ -10090,6 +10090,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
        char tag_buf[30];
        struct attr *attr = path->attr;
        time_t tbuf;
+       char timebuf[32];
        json_object *json_bestpath = NULL;
        json_object *json_cluster_list = NULL;
        json_object *json_cluster_list_list = NULL;
@@ -10983,11 +10984,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
                json_last_update = json_object_new_object();
                json_object_int_add(json_last_update, "epoch", tbuf);
                json_object_string_add(json_last_update, "string",
-                                      ctime(&tbuf));
+                                      ctime_r(&tbuf, timebuf));
                json_object_object_add(json_path, "lastUpdate",
                                       json_last_update);
        } else
-               vty_out(vty, "      Last update: %s", ctime(&tbuf));
+               vty_out(vty, "      Last update: %s", ctime_r(&tbuf, timebuf));
 
        /* Line 10 display PMSI tunnel attribute, if present */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
index e47ea8aa8acf7d937013c9f2220c32d6c1d79283..701c7aba57cfbdb9956e8e3a426d2e0356e3656b 100644 (file)
@@ -689,6 +689,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
        json_object *json_peers = NULL;
        json_object *json_pkt_info = NULL;
        time_t epoch_tbuf, tbuf;
+       char timebuf[32];
 
        if (!ctx)
                return CMD_SUCCESS;
@@ -724,7 +725,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
                json_time = json_object_new_object();
                json_object_int_add(json_time, "epoch", epoch_tbuf);
                json_object_string_add(json_time, "epochString",
-                                      ctime(&epoch_tbuf));
+                                      ctime_r(&epoch_tbuf, timebuf));
                json_object_object_add(json_updgrp, "groupCreateTime",
                                       json_time);
                json_object_string_add(json_updgrp, "afi",
@@ -794,7 +795,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
                        json_object_int_add(json_subgrp_time, "epoch",
                                            epoch_tbuf);
                        json_object_string_add(json_subgrp_time, "epochString",
-                                              ctime(&epoch_tbuf));
+                                              ctime_r(&epoch_tbuf, timebuf));
                        json_object_object_add(json_subgrp, "groupCreateTime",
                                               json_subgrp_time);
                } else {
index c3e55b711e824467d9f3ced74d54bb507d5dddb8..b80e0e787b2c9129189c1e3e9170a526e1041009 100644 (file)
@@ -2598,8 +2598,10 @@ static inline int peer_group_af_configured(struct peer_group *group)
 static inline char *timestamp_string(time_t ts)
 {
        time_t tbuf;
+       char timebuf[32];
+
        tbuf = time(NULL) - (monotime(NULL) - ts);
-       return ctime(&tbuf);
+       return ctime_r(&tbuf, timebuf);
 }
 
 static inline bool peer_established(struct peer_connection *connection)