]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrpd: Use SU_ADDRSTRLEN where appropriate
authorReuben Dowle <reuben.dowle@4rf.com>
Sun, 14 Mar 2021 22:05:56 +0000 (11:05 +1300)
committerReuben Dowle <reuben.dowle@4rf.com>
Thu, 18 Mar 2021 03:35:41 +0000 (16:35 +1300)
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
nhrpd/nhrp_peer.c

index 9899b4fa04f3e4aab0d24c86ced29953ba12b8b2..fcada245ea61d255fdadf4b872b0cede1491309c 100644 (file)
@@ -289,7 +289,7 @@ static int nhrp_peer_defer_vici_request(struct thread *t)
        struct nhrp_vc *vc = p->vc;
        struct interface *ifp = p->ifp;
        struct nhrp_interface *nifp = ifp->info;
-       char buf[256];
+       char buf[SU_ADDRSTRLEN];
        THREAD_OFF(p->t_timer);
 
        if (p->online) {
@@ -314,7 +314,7 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)
        struct nhrp_vc *vc = p->vc;
        struct interface *ifp = p->ifp;
        struct nhrp_interface *nifp = ifp->info;
-       char buf[256];
+       char buf[SU_ADDRSTRLEN];
 
        if (p->online)
                return 1;
@@ -387,7 +387,7 @@ static void nhrp_process_nat_extension(struct nhrp_packet_parser *pp,
                                       union sockunion *proto,
                                       union sockunion *cie_nbma)
 {
-       char buf[2][256];
+       char buf1[SU_ADDRSTRLEN], buf2[SU_ADDRSTRLEN];
        union sockunion cie_proto;
        struct zbuf payload;
        struct nhrp_extension_header *ext;
@@ -413,12 +413,10 @@ static void nhrp_process_nat_extension(struct nhrp_packet_parser *pp,
                                 * the neighbor table in the kernel contains the
                                 * source NBMA address which is not reachable
                                 * since it is behind a NAT device */
+                               if (!sockunion2str(proto, buf1, sizeof(buf1)))
+                                       strlcpy(buf1, "NULL", sizeof(buf1));
                                debugf(NHRP_DEBUG_COMMON,
-                                      "Processing NAT Extension for %s",
-                                      sockunion2str(proto, buf[0],
-                                                    sizeof(buf[0]))
-                                              ? buf[0]
-                                              : "NULL");
+                                      "Processing NAT Extension for %s", buf1);
                                while (nhrp_cie_pull(&payload, pp->hdr,
                                                     cie_nbma, &cie_proto)) {
                                        if (sockunion_family(&cie_proto)
@@ -426,14 +424,14 @@ static void nhrp_process_nat_extension(struct nhrp_packet_parser *pp,
                                                continue;
 
                                        if (!sockunion_cmp(proto, &cie_proto)) {
+                                               if (!sockunion2str(cie_nbma,
+                                                                 buf2,
+                                                                 sizeof(buf2)))
+                                                       strlcpy(buf2, "NULL",
+                                                               sizeof(buf2));
                                                debugf(NHRP_DEBUG_COMMON,
                                                       "cie_nbma for proto %s is %s",
-                                                      buf[0] ? buf[0] : "NULL",
-                                                      sockunion2str(
-                                                              cie_nbma, buf[1],
-                                                              sizeof(buf[1]))
-                                                              ? buf[1]
-                                                              : "NULL");
+                                                      buf1, buf2);
                                                break;
                                        }
                                }