Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2] libnetlink: check error handler is present before a call
@ 2021-07-11 11:15 Alexander Mikhalitsyn
  2021-07-11 11:18 ` Roi Dayan
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Mikhalitsyn @ 2021-07-11 11:15 UTC (permalink / raw)
  To: netdev
  Cc: Alexander Mikhalitsyn, Stephen Hemminger, Roi Dayan,
	Alexander Mikhalitsyn

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>
---
 lib/libnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index e9b8c3bd..d068dbe2 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -686,7 +686,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 */
@@ -729,7 +729,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))
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-11 11:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-11 11:15 [PATCH iproute2] libnetlink: check error handler is present before a call Alexander Mikhalitsyn
2021-07-11 11:18 ` Roi Dayan
2021-07-11 11:26   ` Alexander Mihalicyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox