diff options
author | pali <7141871+pali@users.noreply.github.com> | 2022-08-09 11:22:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 19:22:33 +1000 |
commit | e5d80f67d27e2696154171023a40838b7c2a2544 (patch) | |
tree | 44c60cef8e31f28fce8d7f7b88fd79eccc3f003d /pppd | |
parent | 44609bfc974bdafc0316d069aabf5e2903efa805 (diff) | |
download | ppp-e5d80f67d27e2696154171023a40838b7c2a2544.tar.gz |
pppd: Fix check for incomplete ppp_stats nlmsgerr structure (#356)
Response structure is incomplete when returned length is less than required
structure length.
Signed-off-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'pppd')
-rw-r--r-- | pppd/sys-linux.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index c5ba49d..9c0455c 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -1795,13 +1795,10 @@ get_ppp_stats_rtnetlink(int u, struct pppd_stats *stats) } if (nlresp.nlh.nlmsg_type == NLMSG_ERROR) { - if (nlresplen < offsetof(struct nlresp, __end_err)) { - if (kernel_version >= KVERSION(4,7,0)) - error("get_ppp_stats_rtnetlink: Netlink responded with error: %s (line %d)", strerror(-nlresp.nlerr.error), __LINE__); - } else { - error("get_ppp_stats_rtnetlink: Netlink responded with an error message, but the nlmsgerr structure is incomplete (line %d).", - __LINE__); - } + if (nlresplen < offsetof(struct nlresp, __end_err)) + error("get_ppp_stats_rtnetlink: Netlink responded with an error message, but the nlmsgerr structure is incomplete (line %d).", __LINE__); + else if (kernel_version >= KVERSION(4,7,0)) + error("get_ppp_stats_rtnetlink: Netlink responded with error: %s (line %d)", strerror(-nlresp.nlerr.error), __LINE__); goto err; } |