From 4824ea68a9eab99314e33c134e8f0b5e13899b18 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Thu, 17 Feb 2022 16:52:52 +0800 Subject: [PATCH] libs/libnx: handle the bad message correctly Signed-off-by: chao.an --- libs/libnx/nxmu/nx_eventhandler.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/libnx/nxmu/nx_eventhandler.c b/libs/libnx/nxmu/nx_eventhandler.c index 9dadde485f..d9be5d09f9 100644 --- a/libs/libnx/nxmu/nx_eventhandler.c +++ b/libs/libnx/nxmu/nx_eventhandler.c @@ -146,7 +146,11 @@ int nx_eventhandler(NXHANDLE handle) } while (nbytes < 0); - DEBUGASSERT(nbytes >= sizeof(struct nxclimsg_s)); + if (nbytes < sizeof(struct nxclimsg_s)) + { + _NX_SETERRNO(EBADMSG); + return ERROR; + } /* Dispatch the message appropriately */