From: Renato Westphal Date: Sun, 22 Oct 2017 18:36:13 +0000 (-0200) Subject: ospfd: fix coverity warnings - security best practices violations X-Git-Tag: frr-4.0-dev~191^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a1d6bbb1f30d638a039db2b5e5ef3ea542590b62;p=matthieu%2Ffrr.git ospfd: fix coverity warnings - security best practices violations Signed-off-by: Renato Westphal --- diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 74d5178f55..4e67694059 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -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, diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index b13e833afd..253b272df6 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -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,