From a1d6bbb1f30d638a039db2b5e5ef3ea542590b62 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sun, 22 Oct 2017 16:36:13 -0200 Subject: [PATCH] ospfd: fix coverity warnings - security best practices violations Signed-off-by: Renato Westphal --- ospfd/ospf_lsa.c | 9 +++++---- ospfd/ospf_te.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) 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, -- 2.39.5