Skip to content

Commit

Permalink
solving out of boundaries vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanelmessiry authored Jan 13, 2025
1 parent 4ff8153 commit 5a2a2fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2150,11 +2150,15 @@ string RouteSync::getNextHopIf(struct rtnl_route *route_obj)
char if_name[IFNAMSIZ] = "0";

/* If we cannot get the interface name */
if (!getIfName(if_index, if_name, IFNAMSIZ))
if (!getIfName(if_index, if_name, IFNAMSIZ))
{
strcpy(if_name, "unknown");
strncpy(if_name, "unknown", IFNAMSIZ - 1); // replacing the strcpy with the strncpy to ensure that the copied string will not exceed the size
if_name[IFNAMSIZ - 1] = '\0'; // Enssuring last element in the string is NULL character


}


result += if_name;

if (i + 1 < rtnl_route_get_nnexthops(route_obj))
Expand Down

0 comments on commit 5a2a2fb

Please sign in to comment.