diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index c2f4f1b13..f1cbc576d 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -549,10 +549,10 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const void CannedMessageModule::handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response) { LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n"); - assert(req.decoded.want_response); - - response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag; - strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages); + if(req.decoded.want_response) { + response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag; + strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages); + } // Don't send anything if not instructed to. Better than asserting. } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index e0014f98c..a8f112c94 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -347,10 +347,10 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule void ExternalNotificationModule::handleGetRingtone(const MeshPacket &req, AdminMessage *response) { LOG_INFO("*** handleGetRingtone\n"); - assert(req.decoded.want_response); - - response->which_payload_variant = AdminMessage_get_ringtone_response_tag; - strcpy(response->get_ringtone_response, rtttlConfig.ringtone); + if(req.decoded.want_response) { + response->which_payload_variant = AdminMessage_get_ringtone_response_tag; + strcpy(response->get_ringtone_response, rtttlConfig.ringtone); + } // Don't send anything if not instructed to. Better than asserting. } diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index ecb2ab978..bf0421a9a 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -392,7 +392,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo break; default: - assert(0); // unexpected state - FIXME, make an error code and reboot + assert(0); // unexpected state } return true; // There's no need for others to look at this message. } diff --git a/src/platform/esp32/ESP32CryptoEngine.cpp b/src/platform/esp32/ESP32CryptoEngine.cpp index 93eb76dbd..a7589b2bf 100644 --- a/src/platform/esp32/ESP32CryptoEngine.cpp +++ b/src/platform/esp32/ESP32CryptoEngine.cpp @@ -43,18 +43,21 @@ class ESP32CryptoEngine : public CryptoEngine { if (key.length > 0) { uint8_t stream_block[16]; - static uint8_t scratch[MAX_BLOCKSIZE]; size_t nc_off = 0; LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes); initNonce(fromNode, packetId); - assert(numBytes <= MAX_BLOCKSIZE); - memcpy(scratch, bytes, numBytes); - memset(scratch + numBytes, 0, + if (numBytes <= MAX_BLOCKSIZE) { + static uint8_t scratch[MAX_BLOCKSIZE]; + memcpy(scratch, bytes, numBytes); + memset(scratch + numBytes, 0, sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it) - auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes); - assert(!res); + auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes); + assert(!res); + } else { + LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes); + } } } diff --git a/src/platform/portduino/SimRadio.cpp b/src/platform/portduino/SimRadio.cpp index a2611a464..ce96d02cc 100644 --- a/src/platform/portduino/SimRadio.cpp +++ b/src/platform/portduino/SimRadio.cpp @@ -230,7 +230,12 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p) { LOG_DEBUG("HANDLE RECEIVE INTERRUPT\n"); uint32_t xmitMsec; - assert(isReceiving); + + if (!isReceiving) { + LOG_DEBUG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode\n"); + return; + } + isReceiving = false; // read the number of actually received bytes diff --git a/src/sleep.cpp b/src/sleep.cpp index c85eec3ff..5eb62a1c5 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -163,7 +163,7 @@ static void waitEnterSleep() } // Code that still needs to be moved into notifyObservers - Serial.flush(); // send all our characters before we stop cpu clock + console->flush(); // send all our characters before we stop cpu clock setBluetoothEnable(false); // has to be off before calling light sleep notifySleep.notifyObservers(NULL);