Merge pull request #9595 from s-hadinger/fix-fingerprint-compilation

Fix TLS fingerprint compilation #9582
This commit is contained in:
s-hadinger 2020-10-21 11:33:46 +02:00 committed by GitHub
commit 636c630b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -718,6 +718,10 @@ void SettingsDefaultSet1(void)
// Settings.cfg_crc = 0; // Settings.cfg_crc = 0;
} }
// default Fingerprints in PROGMEM
const uint8_t default_fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 };
const uint8_t default_fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 };
void SettingsDefaultSet2(void) void SettingsDefaultSet2(void)
{ {
memset((char*)&Settings +16, 0x00, sizeof(Settings) -16); memset((char*)&Settings +16, 0x00, sizeof(Settings) -16);
@ -874,10 +878,8 @@ void SettingsDefaultSet2(void)
SettingsUpdateText(SET_STATE_TXT2, MQTT_STATUS_ON); SettingsUpdateText(SET_STATE_TXT2, MQTT_STATUS_ON);
SettingsUpdateText(SET_STATE_TXT3, MQTT_CMND_TOGGLE); SettingsUpdateText(SET_STATE_TXT3, MQTT_CMND_TOGGLE);
SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD); SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD);
static const uint8_t fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 }; memcpy_P(Settings.mqtt_fingerprint[0], default_fingerprint1, sizeof(default_fingerprint1));
static const uint8_t fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 }; memcpy_P(Settings.mqtt_fingerprint[1], default_fingerprint2, sizeof(default_fingerprint2));
memcpy_P(Settings.mqtt_fingerprint[0], fingerprint1, sizeof(fingerprint1));
memcpy_P(Settings.mqtt_fingerprint[1], fingerprint2, sizeof(fingerprint2));
Settings.tele_period = TELE_PERIOD; Settings.tele_period = TELE_PERIOD;
Settings.mqttlog_level = MQTT_LOG_LEVEL; Settings.mqttlog_level = MQTT_LOG_LEVEL;

View File

@ -801,10 +801,14 @@ void CmndMqttFingerprint(void)
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) {
char fingerprint[60]; char fingerprint[60];
if ((XdrvMailbox.data_len > 0) && (XdrvMailbox.data_len < sizeof(fingerprint))) { if ((XdrvMailbox.data_len > 0) && (XdrvMailbox.data_len < sizeof(fingerprint))) {
strlcpy(fingerprint, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? (1 == XdrvMailbox.index) ? MQTT_FINGERPRINT1 : MQTT_FINGERPRINT2 : XdrvMailbox.data, sizeof(fingerprint)); if (SC_DEFAULT == Shortcut()) {
char *p = fingerprint; memcpy_P(Settings.mqtt_fingerprint[XdrvMailbox.index -1], (1 == XdrvMailbox.index) ? default_fingerprint1 : default_fingerprint2, sizeof(default_fingerprint1));
for (uint32_t i = 0; i < 20; i++) { } else {
Settings.mqtt_fingerprint[XdrvMailbox.index -1][i] = strtol(p, &p, 16); strlcpy(fingerprint, (SC_CLEAR == Shortcut()) ? "" : XdrvMailbox.data, sizeof(fingerprint));
char *p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[XdrvMailbox.index -1][i] = strtol(p, &p, 16);
}
} }
restart_flag = 2; restart_flag = 2;
} }