Merge pull request #7957 from s-hadinger/zigbee_fix2

Fix potential crash.
This commit is contained in:
Theo Arends 2020-03-20 10:39:43 +01:00 committed by GitHub
commit cdbe2b60c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 8 deletions

View File

@ -474,7 +474,7 @@ const __FlashStringHelper* getZigbeeStatusMessage(uint8_t status) {
return (const __FlashStringHelper*) statl->status_msg;
}
}
return nullptr;
return F("");
}
#endif // USE_ZIGBEE

View File

@ -506,10 +506,7 @@ void ZCLFrame::parseResponse(void) {
// "Status"
json[F(D_JSON_ZIGBEE_STATUS)] = status;
// "StatusMessage"
const __FlashStringHelper* statm = getZigbeeStatusMessage(status);
if (statm) {
json[F(D_JSON_ZIGBEE_STATUS_MSG)] = statm;
}
json[F(D_JSON_ZIGBEE_STATUS_MSG)] = getZigbeeStatusMessage(status);
// Add Endpoint
json[F(D_CMND_ZIGBEE_ENDPOINT)] = _srcendpoint;
// Add Group if non-zero

View File

@ -347,9 +347,7 @@ int32_t Z_DataConfirm(int32_t res, const class SBuffer &buf) {
char status_message[32];
if (status) { // only report errors
const char * statm = (const char*) getZigbeeStatusMessage(status);
if (nullptr == statm) { statm = PSTR(""); }
strncpy_P(status_message, statm, sizeof(status_message));
strncpy_P(status_message, (const char*) getZigbeeStatusMessage(status), sizeof(status_message));
status_message[sizeof(status_message)-1] = 0; // truncate if needed, strlcpy is safer but strlcpy_P does not exist
Response_P(PSTR("{\"" D_JSON_ZIGBEE_CONFIRM "\":{\"" D_CMND_ZIGBEE_ENDPOINT "\":%d"