summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-13 08:49:50 +0300
committerPaul Buetow <paul@buetow.org>2026-04-13 08:49:50 +0300
commita0e0ccac1b812334d986f524357e1c8b3dcc48e5 (patch)
treed3d62758ee3f874abfdf1914536bb801b329eb0c /src
parent74ae0b479e6f4111ef5f2c93b8099f9149c98328 (diff)
p2: guard streak allocation size overflow
Diffstat (limited to 'src')
-rw-r--r--src/c/fastforge_logic.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/c/fastforge_logic.c b/src/c/fastforge_logic.c
index 8a66804..a21ae36 100644
--- a/src/c/fastforge_logic.c
+++ b/src/c/fastforge_logic.c
@@ -10,6 +10,7 @@ typedef time_t ff_sys_time_t;
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
time_t entry_duration_seconds(const FastEntry *entry) {
@@ -128,6 +129,10 @@ void fastforge_streak_recompute(const FastEntry *entries, int count, time_t now,
return;
}
+ if ((size_t)count > SIZE_MAX / sizeof(time_t)) {
+ return;
+ }
+
size_t completion_capacity = (size_t)count;
time_t *completion_days = malloc(completion_capacity * sizeof(*completion_days));
if (!completion_days) {