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;
}
// default Fingerprints in PROGMEM
const uint8_t default_fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 };
const uint8_t default_fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 };
void SettingsDefaultSet2(void)
{
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_TXT3, MQTT_CMND_TOGGLE);
SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD);
static const uint8_t fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 };
static const uint8_t fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 };
memcpy_P(Settings.mqtt_fingerprint[0], fingerprint1, sizeof(fingerprint1));
memcpy_P(Settings.mqtt_fingerprint[1], fingerprint2, sizeof(fingerprint2));
memcpy_P(Settings.mqtt_fingerprint[0], default_fingerprint1, sizeof(default_fingerprint1));
memcpy_P(Settings.mqtt_fingerprint[1], default_fingerprint2, sizeof(default_fingerprint2));
Settings.tele_period = TELE_PERIOD;
Settings.mqttlog_level = MQTT_LOG_LEVEL;

View File

@ -801,11 +801,15 @@ void CmndMqttFingerprint(void)
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) {
char fingerprint[60];
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()) {
memcpy_P(Settings.mqtt_fingerprint[XdrvMailbox.index -1], (1 == XdrvMailbox.index) ? default_fingerprint1 : default_fingerprint2, sizeof(default_fingerprint1));
} else {
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;
}
ResponseCmndIdxChar(ToHex_P((unsigned char *)Settings.mqtt_fingerprint[XdrvMailbox.index -1], 20, fingerprint, sizeof(fingerprint), ' '));