mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-31 06:36:33 +00:00
Merge pull request #5417 from emontnemery/fix_bad_snprintf
Fix bad snprintf in format()
This commit is contained in:
commit
4ba3331bc7
@ -200,12 +200,13 @@ char* Format(char* output, const char* input, int size)
|
||||
if (token != NULL) {
|
||||
digits = atoi(token);
|
||||
if (digits) {
|
||||
char tmp[size];
|
||||
if (strchr(token, 'd')) {
|
||||
snprintf_P(output, size, PSTR("%s%c0%dd"), output, '%', digits);
|
||||
snprintf_P(output, size, output, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
|
||||
snprintf_P(tmp, size, PSTR("%s%c0%dd"), output, '%', digits);
|
||||
snprintf(output, size, tmp, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
|
||||
} else {
|
||||
snprintf_P(output, size, PSTR("%s%c0%dX"), output, '%', digits);
|
||||
snprintf_P(output, size, output, ESP.getChipId()); // %06X - full chip ID in hex
|
||||
snprintf_P(tmp, size, PSTR("%s%c0%dX"), output, '%', digits);
|
||||
snprintf_P(output, size, tmp, ESP.getChipId()); // %06X - full chip ID in hex
|
||||
}
|
||||
} else {
|
||||
if (strchr(token, 'd')) {
|
||||
@ -619,9 +620,9 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
||||
// We also need at least 3 chars to make a valid version number string.
|
||||
if (((1 == data_len) && (1 == payload)) || ((data_len >= 3) && NewerVersion(dataBuf))) {
|
||||
ota_state_flag = 3;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"), command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_ONE_OR_GT "\"}", command, my_version);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_JSON_ONE_OR_GT "\"}"), command, my_version);
|
||||
}
|
||||
}
|
||||
else if (CMND_OTAURL == command_code) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user