From 04c9b1fe9f05101a77350f430af1722f26119920 Mon Sep 17 00:00:00 2001 From: Avamander Date: Thu, 5 Oct 2023 23:07:53 +0300 Subject: [PATCH] Added a limit to the amount of events that can be stored in the timeline tBLE_ATT_ERR_INVALID_ATTR_VALUE_LENo avoid resource exhaustion --- src/components/ble/weather/WeatherService.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/ble/weather/WeatherService.cpp b/src/components/ble/weather/WeatherService.cpp index 513bb2a16b..83f1c22c29 100644 --- a/src/components/ble/weather/WeatherService.cpp +++ b/src/components/ble/weather/WeatherService.cpp @@ -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(tmpEventType)) { case WeatherData::eventtype::AirQuality: { std::unique_ptr airquality = std::make_unique();