diff options
author | Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com> | 2021-07-11 14:15:46 +0300 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2021-07-11 10:33:44 -0700 |
commit | 115e9870358ba08ec8921ff8f459d379522f0368 (patch) | |
tree | 47eafe3d6f455a5c64dec15340e416f6f8a4e358 | |
parent | 0015ada629a70be0139ee9a0e4d3fb6512f90f56 (diff) | |
download | iproute2-115e9870358ba08ec8921ff8f459d379522f0368.tar.gz |
libnetlink: check error handler is present before a call
Fix nullptr dereference of errhndlr from rtnl_dump_filter_arg
struct in rtnl_dump_done and rtnl_dump_error functions.
Fixes: 459ce6e3d792 ("ip route: ignore ENOENT during save if RT_TABLE_MAIN is being dumped")
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Roi Dayan <roid@nvidia.com>
Cc: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Reported-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r-- | lib/libnetlink.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 5f062c7d..6836c21c 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -731,7 +731,7 @@ static int rtnl_dump_done(struct nlmsghdr *h, if (len < 0) { errno = -len; - if (a->errhndlr(h, a->arg2) & RTNL_SUPPRESS_NLMSG_DONE_NLERR) + if (a->errhndlr && (a->errhndlr(h, a->arg2) & RTNL_SUPPRESS_NLMSG_DONE_NLERR)) return 0; /* check for any messages returned from kernel */ @@ -774,7 +774,7 @@ static int rtnl_dump_error(const struct rtnl_handle *rth, errno == EOPNOTSUPP)) return -1; - if (a->errhndlr(h, a->arg2) & RTNL_SUPPRESS_NLMSG_ERROR_NLERR) + if (a->errhndlr && (a->errhndlr(h, a->arg2) & RTNL_SUPPRESS_NLMSG_ERROR_NLERR)) return 0; if (!(rth->flags & RTNL_HANDLE_F_SUPPRESS_NLERR)) |