From 3e75758eb85777c77e5ca952583a9dd370fd5ca5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 15 Jul 2020 21:06:19 +0200 Subject: Fix uninitialized read of unfinished torrents --- src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 10ba396..b2f238a 100644 --- a/src/main.c +++ b/src/main.c @@ -409,8 +409,10 @@ static void torrent_list_check_new_downloads_callback(int id, const char *name, } } else { if(id >= unfinished_torrents->size) { + int prev_size = unfinished_torrents->size; unfinished_torrents->size = id + 128; unfinished_torrents->items = realloc_or_crash(unfinished_torrents->items, unfinished_torrents->size); + memset(unfinished_torrents->items + prev_size, 0, unfinished_torrents->size - prev_size); } unfinished_torrents->items[id] = 1; } @@ -434,8 +436,9 @@ static void sync_rss_html(char *rss_config_dir, char *html_config_dir, char *pro int check_torrent_status_rate_sec = 15; UnfinishedTorrents unfinished_torrents; - unfinished_torrents.items = alloc_or_crash(1024); unfinished_torrents.size = 1024; + unfinished_torrents.items = alloc_or_crash(unfinished_torrents.size); + memset(unfinished_torrents.items, 0, unfinished_torrents.size); automedia_running = 1; /* running is set to 0 in SIGINT signal handler (ctrl+c) */ -- cgit v1.2.3-70-g09d2