From 841b283c0f48f5218a28fdefcbd64e41cf00d25b Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 26 Apr 2024 07:04:16 +0200 Subject: [PATCH] [LoRaWAN] Use dynamic array instead of VLA --- src/protocols/LoRaWAN/LoRaWAN.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index a80bafd9..3922f145 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -1023,7 +1023,7 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf // assume maximum possible buffer size uint8_t foptsBuff[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN]; #else - uint8_t foptsBuff[foptsLen]; + uint8_t* foptsBuff = new uint8_t[foptsLen]; #endif uint8_t* foptsPtr = foptsBuff; @@ -1052,6 +1052,9 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf // encrypt it processAES(foptsBuff, foptsLen, this->nwkSEncKey, &uplinkMsg[RADIOLIB_LORAWAN_FHDR_FOPTS_POS], this->fcntUp, RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK, 0x01, true); + #if !RADIOLIB_STATIC_ONLY + delete[] foptsBuff; + #endif } // set the port