]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: fix coverity warnings - security best practices violations
authorRenato Westphal <renato@opensourcerouting.org>
Sun, 22 Oct 2017 18:36:13 +0000 (16:36 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 24 Oct 2017 21:30:30 +0000 (19:30 -0200)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ospfd/ospf_lsa.c
ospfd/ospf_te.c

index 74d5178f55cded09649b7552d6a2a41a38601788..4e6769405952f8723660785a80ad8395d914eb46 100644 (file)
@@ -284,12 +284,12 @@ const char *dump_lsa_key(struct ospf_lsa *lsa)
 
        if (lsa != NULL && (lsah = lsa->data) != NULL) {
                char id[INET_ADDRSTRLEN], ar[INET_ADDRSTRLEN];
-               strcpy(id, inet_ntoa(lsah->id));
-               strcpy(ar, inet_ntoa(lsah->adv_router));
+               strlcpy(id, inet_ntoa(lsah->id), sizeof(id));
+               strlcpy(ar, inet_ntoa(lsah->adv_router), sizeof(ar));
 
                sprintf(buf, "Type%d,id(%s),ar(%s)", lsah->type, id, ar);
        } else
-               strcpy(buf, "NULL");
+               strlcpy(buf, "NULL", sizeof(buf));
 
        return buf;
 }
@@ -2713,7 +2713,8 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi,
                                              new->data->type, NULL));
                        break;
                default:
-                       strcpy(area_str, inet_ntoa(new->area->area_id));
+                       strlcpy(area_str, inet_ntoa(new->area->area_id),
+                               sizeof(area_str));
                        zlog_debug("LSA[%s]: Install %s to Area %s",
                                   dump_lsa_key(new),
                                   lookup_msg(ospf_lsa_type_msg,
index b13e833afd9405cd9a293d5e24387f6ec3bbb64d..253b272df67f266367d7bded1de589ba9a6bfb31 100644 (file)
@@ -1252,7 +1252,7 @@ static int ospf_mpls_te_lsa_originate1(struct ospf_area *area,
 
        if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) {
                char area_id[INET_ADDRSTRLEN];
-               strcpy(area_id, inet_ntoa(area->area_id));
+               strlcpy(area_id, inet_ntoa(area->area_id), sizeof(area_id));
                zlog_debug(
                        "LSA[Type%d:%s]: Originate Opaque-LSA/MPLS-TE: Area(%s), Link(%s)",
                        new->data->type, inet_ntoa(new->data->id), area_id,