fix cppcheck

This commit is contained in:
Thomas Göttgens
2023-01-16 11:08:48 +01:00
parent aca1241a7f
commit 2b9f01f0e4
4 changed files with 13 additions and 13 deletions

View File

@@ -24,10 +24,10 @@ bool hasOpenEditTransaction;
static const char *secretReserved = "sekrit";
/// If buf is the reserved secret word, replace the buffer with currentVal
static void writeSecret(char *buf, const char *currentVal)
static void writeSecret(char *buf, size_t bufsz, const char *currentVal)
{
if (strcmp(buf, secretReserved) == 0) {
strncpy(buf, currentVal, sizeof(buf));
strncpy(buf, currentVal, bufsz);
}
}
@@ -381,7 +381,7 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
LOG_INFO("Getting config: Network\n");
res.get_config_response.which_payload_variant = Config_network_tag;
res.get_config_response.payload_variant.network = config.network;
writeSecret(res.get_config_response.payload_variant.network.wifi_psk, config.network.wifi_psk);
writeSecret(res.get_config_response.payload_variant.network.wifi_psk, sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk);
break;
case AdminMessage_ConfigType_DISPLAY_CONFIG:
LOG_INFO("Getting config: Display\n");

View File

@@ -200,7 +200,7 @@ int32_t SerialModule::runOnce()
// in NMEA mode send out GGA every 2 seconds, Don't read from Port
if (millis() - lastNmeaTime > 2000) {
lastNmeaTime = millis();
printGGA(outbuf, nodeDB.getNode(myNodeInfo.my_node_num)->position);
printGGA(outbuf, sizeof(outbuf), nodeDB.getNode(myNodeInfo.my_node_num)->position);
Serial2.printf("%s", outbuf);
}
} else {
@@ -293,7 +293,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
decoded = &scratch;
}
// send position packet as WPL to the serial port
printWPL(outbuf, *decoded, nodeDB.getNode(getFrom(&mp))->user.long_name);
printWPL(outbuf, sizeof(outbuf), *decoded, nodeDB.getNode(getFrom(&mp))->user.long_name);
Serial2.printf("%s", outbuf);
}
}