Skip to content

MessageDecoder: add check on thing_id length #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: rel-2.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@
#define AIOT_CONFIG_RP2040_OTA_HTTP_HEADER_RECEIVE_TIMEOUT_ms (10*1000UL)
#define AIOT_CONFIG_RP2040_OTA_HTTP_DATA_RECEIVE_TIMEOUT_ms (4*60*1000UL)

#define AIOT_CONFIG_LIB_VERSION "1.15.1"
#define AIOT_CONFIG_LIB_VERSION "2.0.0"

#endif /* ARDUINO_AIOTC_CONFIG_H_ */
7 changes: 7 additions & 0 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
}
break;

case CommandId::TimezoneCommandDownId:
{
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] timezone update received", __FUNCTION__, millis());
_thing.handleMessage((Message*)&command);
}
break;

case CommandId::LastValuesUpdateCmdId:
{
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] last values received", __FUNCTION__, millis());
Expand Down
8 changes: 8 additions & 0 deletions src/ArduinoIoTCloudThing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ void ArduinoCloudThing::update() {
nextState = State::Connected;
}
break;

/* We have received a timezone update */
case TimezoneCommandDownId:
{
TimezoneCommandDown * cmd = (TimezoneCommandDown *)_command;
TimeService.setTimeZoneData(cmd->params.offset, cmd->params.until);
}
break;

/* We have received a reset command */
case ResetCmdId:
Expand Down
7 changes: 7 additions & 0 deletions src/cbor/MessageDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ CBORMessageDecoder::ArrayParserState CBORMessageDecoder::decodeThingUpdateCmd(Cb
return ArrayParserState::Error;
}

size_t thingIdLen = strlen(thingCommand->params.thing_id);

// thing_id length normally is 36, or 0 in case of device not attached to any thing
if (!((thingIdLen == sizeof(thingCommand->params.thing_id) -1) || (thingIdLen == 0))) {
return ArrayParserState::Error;
}

return ArrayParserState::LeaveArray;
}

Expand Down