From fa411c8b184fd117d08c4e814f543d0e8663ba63 Mon Sep 17 00:00:00 2001 From: klemek Date: Mon, 10 Nov 2025 14:38:01 +0100 Subject: [PATCH] fix: security issues --- src/file.c | 2 +- src/tempo.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/file.c b/src/file.c index 1c5696e..ed8a6ab 100644 --- a/src/file.c +++ b/src/file.c @@ -61,7 +61,7 @@ bool file_update(File *file) { // close file fclose(file_pointer); // append null byte - file->content[length] = '\0'; + file->content[length] = 0; // read last update time file->last_write = get_file_time(file); diff --git a/src/tempo.c b/src/tempo.c index ae8ecd1..ebc17eb 100644 --- a/src/tempo.c +++ b/src/tempo.c @@ -52,6 +52,10 @@ static long get_average_tap_duration(Tempo tempo) { running_total += tempo.tap_durations[i]; } + if (amount == 0) { + amount = 1; // should never happen + } + average_tap_duration = running_total / amount; if (average_tap_duration < MIN_BEAT_LENGTH) { return MIN_BEAT_LENGTH;