From 83cd3bb631131a116f024cfacfd687e8c4855fd1 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 6 Nov 2026 08:28:16 +0100 Subject: Bound what load_state will accept for an age --- src/opentracker.c | 8 ++++---- src/trackerlogic.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/opentracker.c b/src/opentracker.c index 65fe382..e467ce6 100644 --- a/src/opentracker.c +++ b/src/opentracker.c @@ -300,7 +300,7 @@ void load_state(const char *const state_filename) { FILE *state_filehandle; char inbuf[512]; ot_hash infohash; - uint64_t base, downcount; + uint64_t age, downcount; int consumed; state_filehandle = fopen(state_filename, "r"); @@ -318,12 +318,12 @@ void load_state(const char *const state_filename) { continue; i = 2 * sizeof(ot_hash); - if (inbuf[i++] != ':' || !(consumed = scan_uint(inbuf + i, &base, UINT64_MAX))) + if (inbuf[i++] != ':' || !(consumed = scan_uint(inbuf + i, &age, OT_TORRENT_TIMEOUT))) continue; i += consumed; - if (inbuf[i++] != ':' || !(consumed = scan_uint(inbuf + i, &downcount, UINT64_MAX))) + if (inbuf[i++] != ':' || !(consumed = scan_uint(inbuf + i, &downcount, SIZE_MAX))) continue; - add_torrent_from_saved_state(infohash, base, downcount); + add_torrent_from_saved_state(infohash, (ot_time)age, (size_t)downcount); } fclose(state_filehandle); diff --git a/src/trackerlogic.c b/src/trackerlogic.c index 2313379..9fd6114 100644 --- a/src/trackerlogic.c +++ b/src/trackerlogic.c @@ -45,7 +45,7 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time age, size_t down_c ot_torrent *torrent; ot_vector *torrents_list; - if (age > OT_TORRENT_TIMEOUT) + if (age < 0 || age > OT_TORRENT_TIMEOUT) return; torrents_list = mutex_bucket_lock_by_hash(hash); -- cgit v1.3