mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-12 04:15:06 -05:00
libalpm: Do a sanity check before manipulating final DB URL
The change in commit 9d96bed9d6
causes download errors for the .db.sig file
in case the final URL for the .db file contains query strings or other
unexpected stuff. This commit isn't intended to be a total solution, but it
should eliminate the problem in the most obvious cases.
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d568a4335b
commit
d5536d3eb3
@ -241,9 +241,16 @@ 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 -
|
|
||||||
this information is only available from the internal downloader */
|
/* check if the final URL from internal downloader looks reasonable */
|
||||||
if(handle->fetchcb == NULL) {
|
if(final_db_url != NULL) {
|
||||||
|
if(strlen(final_db_url) < 3 || strcmp(final_db_url + strlen(final_db_url) - 3, ".db") != 0) {
|
||||||
|
final_db_url = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if we downloaded a DB, we want the .sig from the same server */
|
||||||
|
if(final_db_url != 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 {
|
} else {
|
||||||
@ -254,7 +261,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
|
|||||||
/* 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) {
|
if(final_db_url != NULL) {
|
||||||
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
|
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
|
||||||
} else {
|
} else {
|
||||||
snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
|
snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
|
||||||
|
Loading…
Reference in New Issue
Block a user