1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Fix crash when using external downloader

Commit 9d96bed9 attempts to use the same effective URL for the db and its
signature download.  However, this information is not available when we use
an external downloader, resulting in a crash.

Fall back to the old method when the effective URL is unavailable.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2014-11-17 17:13:48 +10:00
parent 4c1f41a7c1
commit 8c00dd7341

View File

@ -241,12 +241,25 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
unlink(sigpath); unlink(sigpath);
free(sigpath); free(sigpath);
/* if we downloaded a DB, we want the .sig from the same server */ /* if we downloaded a DB, we want the .sig from the same server -
this information is only available from the internal downloader */
if(handle->fetchcb == NULL) {
/* print final_db_url into a buffer (leave space for .sig) */ /* print final_db_url into a buffer (leave space for .sig) */
len = strlen(final_db_url) + 5; len = strlen(final_db_url) + 5;
} else {
/* print server + filename into a buffer (leave space for .sig) */
len = strlen(server) + strlen(db->treename) + 9;
}
/* TODO fix leak syncpath and umask unset */ /* TODO fix leak syncpath and umask unset */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
if(handle->fetchcb == NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url); snprintf(payload.fileurl, len, "%s.sig", final_db_url);
} else {
snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
}
payload.handle = handle; payload.handle = handle;
payload.force = 1; payload.force = 1;
payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL); payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL);