ospfd: Prevent crash by accessing memory not owned.

When allocating memory for the `struct ospf_metric` we
were using `uint32_t` instead of the actual size of this
structure.  When we wrote to it we would be writing
into other people's memory.

Found-by: Amol Lad
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2020-11-25 09:49:28 -05:00
parent f286bcf5fc
commit cf0f13de29

View File

@ -416,7 +416,7 @@ static void *route_set_metric_compile(const char *arg)
{ {
struct ospf_metric *metric; struct ospf_metric *metric;
metric = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t)); metric = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(*metric));
metric->used = false; metric->used = false;
if (all_digit(arg)) if (all_digit(arg))