summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_sync.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-11-17 08:13:48 +0100
committerAllan McRae <allan@archlinux.org>2014-11-17 08:13:48 +0100
commit8c00dd7341e6df4ebe8c6ac9d9347acdcbb003b7 (patch)
treeb276deabe17af6a3a643da9dae93fede5f215d52 /lib/libalpm/be_sync.c
parent4c1f41a7c18355542d9d7f5c58ac5a026a71bb4d (diff)
downloadpacman-8c00dd7341e6df4ebe8c6ac9d9347acdcbb003b7.tar.gz
pacman-8c00dd7341e6df4ebe8c6ac9d9347acdcbb003b7.tar.xz
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>
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r--lib/libalpm/be_sync.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 62fd0f04..52459483 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -241,12 +241,25 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
unlink(sigpath);
free(sigpath);
- /* if we downloaded a DB, we want the .sig from the same server */
- /* print final_db_url into a buffer (leave space for .sig) */
- len = strlen(final_db_url) + 5;
+ /* 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) */
+ 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 */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
- snprintf(payload.fileurl, len, "%s.sig", final_db_url);
+
+ if(handle->fetchcb == NULL) {
+ 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.force = 1;
payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL);