Commit 3401f9e1 authored by Allan McRae's avatar Allan McRae
Browse files

libalpm: prevent download error pages ending up in package files

Some servers respond with error pages (e.g. 404.html) when a package is
not present. These were getting written to packages before moving onto
the next server. Reset the download progress on 400+ error conditions
to avoid this.

Signed-off-by: Allan McRae's avatarAllan McRae <>
parent 6f35ce15
......@@ -510,6 +510,16 @@ static int curl_check_finished_download(CURLM *curlm, CURLMsg *msg,
payload->remote_name, hostname, payload->error_buffer);
server_soft_error(handle, payload->fileurl);
if(fstat(fileno(payload->localf), &st) == 0 && st.st_size != payload->initial_size) {
/* an html error page was written to the file, reset it */
if(ftruncate(fileno(payload->localf), payload->initial_size)) {
fseek(payload->localf, payload->initial_size, SEEK_SET);
if(curl_retry_next_server(curlm, curl, payload) == 0) {
return 2;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment