From b9a2318becfc9d6ffb92e602adf433faa8cec383 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 14 May 2011 12:54:03 -0400 Subject: trans.c: create transaction prior to checking DB version The addition of the DB version check introduces a lag time between the lockfile creation and the transaction initialization. In cases where the local DB is large enough and/or the user's disk is slow enough, this time is significant enough that its possible for a user to send a SIGINT and leave behind a db.lck file. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/trans.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index c5af7c69..7affbfbd 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -120,15 +120,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, } } - /* check database version */ - db_version = _alpm_db_version(handle->db_local); - if(db_version < required_db_version) { - _alpm_log(PM_LOG_ERROR, - _("%s database version is too old\n"), handle->db_local->treename); - remove_lock(handle); - RET_ERR(PM_ERR_DB_VERSION, -1); - } - trans = _alpm_trans_new(); if(trans == NULL) { RET_ERR(PM_ERR_MEMORY, -1); @@ -142,6 +133,16 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, handle->trans = trans; + /* check database version */ + db_version = _alpm_db_version(handle->db_local); + if(db_version < required_db_version) { + _alpm_log(PM_LOG_ERROR, + _("%s database version is too old\n"), handle->db_local->treename); + remove_lock(handle); + _alpm_trans_free(trans); + RET_ERR(PM_ERR_DB_VERSION, -1); + } + return(0); } -- cgit v1.2.3-24-g4f1b From aec60e37822509a1ca7fc53244878d3f1505d964 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 16 May 2011 11:50:13 -0500 Subject: Fix segfault when uninstalling broken backed-up symlink Issue FS#24230. If a symlink is broken and included in the removal process of a package, we blew up and segfaulted due to alpm_compute_md5sum() returning NULL and then performing a strcmp() operation. Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 7c8a99fb..22ae2bb8 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -266,7 +266,7 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, FREE(pkghash); } else { char *filehash = alpm_compute_md5sum(file); - int cmp = strcmp(filehash,pkghash); + int cmp = filehash ? strcmp(filehash, pkghash) : 0; FREE(filehash); FREE(pkghash); if(cmp != 0) { -- cgit v1.2.3-24-g4f1b