From a12a4ea3960c98817aa60df5a8879d118a16e2a7 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 28 Aug 2011 19:46:09 -0500 Subject: Check local database status flag in db_write sanity check block Do all the checks at once; this also avoids the 'return' call after we have allocated memory for "pkgpath" as well as tweaked the umask. Signed-off-by: Dan McGee --- lib/libalpm/be_local.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index f53bd640..1a46dfdf 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -750,7 +750,7 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq int retval = 0; char *pkgpath = NULL; - if(db == NULL || info == NULL) { + if(db == NULL || info == NULL || !(db->status & DB_STATUS_LOCAL)) { return -1; } @@ -759,10 +759,6 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq /* make sure we have a sane umask */ oldmask = umask(0022); - if(strcmp(db->treename, "local") != 0) { - return -1; - } - /* DESC */ if(inforeq & INFRQ_DESC) { _alpm_log(db->handle, ALPM_LOG_DEBUG, "writing %s-%s DESC information back to db\n", -- cgit v1.2.3-24-g4f1b