Skip to content

Commit

Permalink
Added a limit to the amount of events that can be stored in the timel…
Browse files Browse the repository at this point in the history
…ine tBLE_ATT_ERR_INVALID_ATTR_VALUE_LENo avoid resource exhaustion
  • Loading branch information
Avamander committed Oct 5, 2023
1 parent 46b664b commit 04c9b1f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/ble/weather/WeatherService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ namespace Pinetime {
return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
}

// Enforce a reasonable limit to the amount of RAM that can be used
if (GetTimelineLength() > WeatherData::eventtype::Length) {
return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
}

switch (static_cast<WeatherData::eventtype>(tmpEventType)) {
case WeatherData::eventtype::AirQuality: {
std::unique_ptr<WeatherData::AirQuality> airquality = std::make_unique<WeatherData::AirQuality>();
Expand Down

0 comments on commit 04c9b1f

Please sign in to comment.