diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-15 21:06:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-15 21:06:19 +0200 |
commit | 3e75758eb85777c77e5ca952583a9dd370fd5ca5 (patch) | |
tree | f097adaae08f4895af93aedb93dcfcd79e540bca | |
parent | 98bd861a45437b1ade7e6b74f57e5c4f0812a8f6 (diff) |
Fix uninitialized read of unfinished torrents
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | automedia | bin | 112552 -> 112552 bytes | |||
-rw-r--r-- | src/main.c | 5 |
3 files changed, 5 insertions, 2 deletions
@@ -13,7 +13,7 @@ Run automedia without any options to see all options. 4. Convert python plugins to C. # Requirements ## System -transmission-cli, notify-send (optional) +curl, transmission-cli, notify-send (optional) ## Python lxml, requests, pure_protobuf (optional, used with mangaplus.shueisha.co.jp) # Requirements when using read_manga.py Binary files differ@@ -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) */ |