]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: check error handler is present before a call
authorAlexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Sun, 11 Jul 2021 11:15:46 +0000 (14:15 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 11 Jul 2021 17:33:44 +0000 (10:33 -0700)
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>
lib/libnetlink.c

index 5f062c7d5442b2a0a14dd38229373c255488073f..6836c21c903d4ee9e722995964657bd999cd204c 100644 (file)
@@ -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))