mnl_cb_error() negates the error field of an NLMSG_ERROR message to get a positive errno. For INT_MIN the negation overflows, which is undefined behaviour. No errno has that value, so report the message as malformed with EBADMSG instead. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Florian Stosse --- src/callback.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/callback.c b/src/callback.c index 703ae80..660c90a 100644 --- a/src/callback.c +++ b/src/callback.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "internal.h" @@ -25,7 +26,9 @@ static int mnl_cb_error(const struct nlmsghdr *nlh, void *data) return MNL_CB_ERROR; } /* Netlink subsystems returns the errno value with different signess */ - if (err->error < 0) + if (err->error == INT_MIN) + errno = EBADMSG; + else if (err->error < 0) errno = -err->error; else errno = err->error; -- 2.56.0.windows.4