From 952ee5e6cb8bb1849c1bceedae38744935c82fca Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 14 Mar 2012 23:04:43 -0400 Subject: dload: reset payload filename members before download To avoid conflicts on reusing a payload after a failed download, ensure that we reset the filename hints in the payload struct prior to the download operation. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index ee95e8a7..9d982183 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -394,6 +394,11 @@ static int curl_download_internal(struct dload_payload *payload, CURL *curl = get_libcurl_handle(handle); handle->pm_errno = 0; + /* make sure these are NULL */ + FREE(payload->tempfile_name); + FREE(payload->destfile_name); + FREE(payload->content_disp_name); + payload->tempfile_openmode = "wb"; if(!payload->remote_name) { STRDUP(payload->remote_name, get_filename(payload->fileurl), -- cgit v1.2.3-24-g4f1b From f41037358af167424403d30a3b972b1fd733c755 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 14 Mar 2012 23:06:24 -0400 Subject: lib/sync: avoid unwanted unlink after download fail In case we have a mirror failure, unlink_on_fail would remain set, causing an interrupt in a successive download attempt to be wrongly unlinked. This also fixes a memory leak in the url member, as we would allocate over the previous, unfreed URL. Signed-off-by: Dave Reisner --- lib/libalpm/sync.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 185878aa..05959ca8 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -896,6 +896,8 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas) if(ret != -1) { break; } + free(payload->fileurl); + payload->unlink_on_fail = 0; } if(ret == -1) { errors++; -- cgit v1.2.3-24-g4f1b