From 4f31eec94e41ddc35b74a5a7e872701678d37f56 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 12 May 2019 14:42:27 -0600 Subject: [PATCH] libs/libnx/nxmu/: Add a few bad input parameter checks. configs/lpcxpresso-lpc54628/twm4nx/defconfig: Need to enable the NX library. --- configs/lpcxpresso-lpc54628/twm4nx/defconfig | 4 ++++ libs/libnx/nxmu/nx_setsize.c | 2 +- libs/libnx/nxtk/nxtk_setsize.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configs/lpcxpresso-lpc54628/twm4nx/defconfig b/configs/lpcxpresso-lpc54628/twm4nx/defconfig index d2286d478b..97ee27cf39 100644 --- a/configs/lpcxpresso-lpc54628/twm4nx/defconfig +++ b/configs/lpcxpresso-lpc54628/twm4nx/defconfig @@ -53,6 +53,10 @@ CONFIG_MM_REGIONS=2 CONFIG_MQ_MAXMSGSIZE=64 CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LIBRARY=y +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y CONFIG_NX=y CONFIG_NXFONT_SANS22X29B=y CONFIG_NXFONT_SANS23X27=y diff --git a/libs/libnx/nxmu/nx_setsize.c b/libs/libnx/nxmu/nx_setsize.c index 6792328085..33458874d1 100644 --- a/libs/libnx/nxmu/nx_setsize.c +++ b/libs/libnx/nxmu/nx_setsize.c @@ -71,7 +71,7 @@ int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size) struct nxsvrmsg_setsize_s outmsg; #ifdef CONFIG_DEBUG_FEATURES - if (!wnd || !size) + if (wnd == NULL || size == NULL || size->w < 0 || size->h < 0) { set_errno(EINVAL); return ERROR; diff --git a/libs/libnx/nxtk/nxtk_setsize.c b/libs/libnx/nxtk/nxtk_setsize.c index 3ca99e17f0..577ec1f6f0 100644 --- a/libs/libnx/nxtk/nxtk_setsize.c +++ b/libs/libnx/nxtk/nxtk_setsize.c @@ -76,7 +76,7 @@ int nxtk_setsize(NXTKWINDOW hfwnd, FAR const struct nxgl_size_s *size) int ret; #ifdef CONFIG_DEBUG_FEATURES - if (hfwnd == NULL || size == NULL) + if (hfwnd == NULL || size == NULL || size->w < 0 || size->h < 0) { set_errno(EINVAL); return ERROR;