Skip to content

Commit

Permalink
Disables netlink RTA_METRICS exception.
Browse files Browse the repository at this point in the history
RTA_METRIC response processing is far more complex than just casting
data to unsigned int. Data parameter is an array of rtattr. So to not
block possible GNU/Linux distributions than can be impacted by exception, we
disable it and set metric to 0 (as it is by default).
  • Loading branch information
s-vincent committed Jul 9, 2018
1 parent b4b4c6d commit 1cf517b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libs/netlinkplus/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,18 @@ namespace netlinkplus
}
case RTA_METRICS:
{
if (buffer_size(data) != sizeof(result.priority))
if (buffer_size(data) != sizeof(result.metric))
{
throw boost::system::system_error(make_error_code(netlinkplus_error::invalid_route_metric));
// On some old GNU/Linux distributions, it causes issues.
// In addition, RTA_METRICS processing is more complex than
// that (data should be an array of rtattr structures).
// So disable the exception from now.
//throw boost::system::system_error(make_error_code(netlinkplus_error::invalid_route_metric));
result.metric = 0;
break;
}

// TODO handle properly RTA_METRICS
result.metric = *boost::asio::buffer_cast<unsigned int*>(data);

break;
Expand Down

0 comments on commit 1cf517b

Please sign in to comment.