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>
This commit is contained in:
parent
15be417c17
commit
4fead44e3c
2 changed files with 10 additions and 5 deletions
|
@ -1311,10 +1311,9 @@ int alpm_db_get_valid(alpm_db_t *db);
|
|||
alpm_list_t *alpm_db_get_servers(const alpm_db_t *db);
|
||||
|
||||
/** Sets the list of servers for the database to use.
|
||||
* @param db the database to set the servers
|
||||
* @param servers a char* list of servers. Note: the database will
|
||||
* take ownership of the list and it should no longer be
|
||||
* freed by the caller
|
||||
* @param db the database to set the servers. The list will be duped and
|
||||
* the original will still need to be freed by the caller.
|
||||
* @param servers a char* list of servers.
|
||||
*/
|
||||
int alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue