diff --git a/arch/sim/src/cmake/Toolchain.cmake b/arch/sim/src/cmake/Toolchain.cmake index c4c0cff080a91..118b62bbc537b 100644 --- a/arch/sim/src/cmake/Toolchain.cmake +++ b/arch/sim/src/cmake/Toolchain.cmake @@ -148,6 +148,7 @@ if(NOT WIN32) -ffunction-sections -fdata-sections -Wall + -Wvla -Wshadow -Wundef -Wno-attributes diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index c56772dc04309..4b392c00171da 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -127,8 +127,8 @@ ARCHCXXFLAGS += -fvisibility=hidden ARCHCFLAGS += -ffunction-sections -fdata-sections ARCHCXXFLAGS += -ffunction-sections -fdata-sections -ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas -ARCHCXXFLAGS += -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas +ARCHCFLAGS += -Wall -Wvla -Wstrict-prototypes -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas +ARCHCXXFLAGS += -Wall -Wvla -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y) ARCHCXXFLAGS += -nostdinc++ diff --git a/net/usrsock/usrsock_sendmsg.c b/net/usrsock/usrsock_sendmsg.c index 048791193327f..ab844a722d952 100644 --- a/net/usrsock/usrsock_sendmsg.c +++ b/net/usrsock/usrsock_sendmsg.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -142,9 +143,18 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn, { }; - struct iovec bufs[2 + msg->msg_iovlen]; + struct iovec *bufs; + size_t iovlen; + int ret; int i; + iovlen = 2 + msg->msg_iovlen; + bufs = kmm_malloc(sizeof(*bufs) * iovlen); + if (bufs == NULL) + { + return -ENOMEM; + } + if (msg->msg_namelen > UINT16_MAX) { msg->msg_namelen = UINT16_MAX; @@ -174,7 +184,9 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn, memcpy(&bufs[2], msg->msg_iov, sizeof(struct iovec) * msg->msg_iovlen); - return usrsock_do_request(conn, bufs, nitems(bufs)); + ret = usrsock_do_request(conn, bufs, iovlen); + kmm_free(bufs); + return ret; } /****************************************************************************