diff options
author | morganamilo <morganamilo@archlinux.org> | 2021-05-09 14:18:38 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2021-05-09 14:54:20 +0200 |
commit | 4fead44e3ce97d3a83ca6bab393d480746ba9227 (patch) | |
tree | 33ea7561d706a5b0951638e021becca6049c3b30 /lib/libalpm/db.c | |
parent | 15be417c17809cbf2721a3fb0c519ee910b8d0a6 (diff) | |
download | pacman-4fead44e3ce97d3a83ca6bab393d480746ba9227.tar.gz pacman-4fead44e3ce97d3a83ca6bab393d480746ba9227.tar.xz |
libalpm: clone data on alpm_db_set_servers
Every alpm_option_set function clones the input so lets be more
consistent. Also this fixes servers not being sanatized.
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r-- | lib/libalpm/db.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 8511bb83..b8d1b157 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -139,9 +139,15 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db) int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers) { + alpm_list_t *i; ASSERT(db != NULL, return -1); FREELIST(db->servers); - db->servers = servers; + for(i = servers; i; i = i->next) { + char *url = i->data; + if(alpm_db_add_server(db, url) != 0) { + return -1; + } + } return 0; } |