diff --git a/src/repo/async.c b/src/repo/async.c index 36bd2e7949b6645ec8fb8eb200c6d942e100ef4e..8fdb2ce7756dffcb677eb6ccc215f48f40060d81 100644 --- a/src/repo/async.c +++ b/src/repo/async.c @@ -88,7 +88,7 @@ __handle_got_json(struct lkt_thread *self, struct lkt_repo *repo, struct json_ob kara->filename[++kara_dir_len] = 0; } integer = snprintf(kara->filename + kara_dir_len, PATH_MAX - kara_dir_len, "%d", integer); - kara->filename[PATH_MAX] = 0; + kara->filename[PATH_MAX - 1] = 0; fprintf(stderr, " . __handle_got_json: Crafted filename is '%s'\n", kara->filename); if (!kara) { diff --git a/src/repo/curl.c b/src/repo/curl.c index 277c489234cbffbe58c12222e25af3b028fb96d6..0f4b8191e615353459a2d77669bf9dace72aa147 100644 --- a/src/repo/curl.c +++ b/src/repo/curl.c @@ -229,6 +229,7 @@ repo_get_id(struct lkt_repo *const repo, const uint64_t id, struct kara_metadata memset(url, 0, URL_MAX_LEN * sizeof(char)); snprintf(url, URL_MAX_LEN - 1, repo->get_id_json, id); + url[URL_MAX_LEN - 1] = 0; curl_handle = curl_easy_init(); curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_mem__); @@ -342,6 +343,7 @@ repo_download_id_sync(struct lkt_repo *const repo, sqlite3 *db, const uint64_t i memset(url, 0, URL_MAX_LEN * sizeof(char)); snprintf(url, URL_MAX_LEN - 1, repo->get_id_file, id); + url[URL_MAX_LEN - 1] = 0; curl_handle = curl_easy_init(); curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_disk__);