From eedf4f4e630f98350090ef2824b0981ffb4b7a4a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 10 Dec 2010 19:43:59 -0600 Subject: Fix possible null pointer deref in check_arch If we have a corrupted database, a package can come through without an arch, causing the code to blow up when making strcmp() calls. It might even be possible with perfectly valid database entries lacking an 'arch =' line. This behavior was seen as at least one of the problems in FS#21668. Ensure pkgarch is not null before doing anything further. Signed-off-by: Dan McGee --- lib/libalpm/trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 49fc0f67..02612ec1 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -107,7 +107,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs) for(i = pkgs; i; i = i->next) { pmpkg_t *pkg = i->data; const char *pkgarch = alpm_pkg_get_arch(pkg); - if(strcmp(pkgarch,arch) && strcmp(pkgarch,"any")) { + if(pkgarch && strcmp(pkgarch, arch) && strcmp(pkgarch, "any")) { char *string; const char *pkgname = alpm_pkg_get_name(pkg); const char *pkgver = alpm_pkg_get_version(pkg); -- cgit v1.2.3-24-g4f1b From 5c8083baa4a831b16adcc3c1c35d7438f5bdcc3e Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Thu, 14 Oct 2010 21:50:19 +0200 Subject: be_files: write EPOCH instead of FORCE This patch is only meant for 3.4.x. It prepares the place for the future epoch-aware release. All force packages that get reinstalled or upgraded will get an EPOCH entry in the local database, and thus the new pacman with epoch won't reinstall them by mistake on the first -Su. Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- lib/libalpm/be_files.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 877bc505..c0b8b439 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -810,10 +810,11 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } fprintf(fp, "\n"); } - if(info->force) { - fprintf(fp, "%%FORCE%%\n\n"); - } if(local) { + if(info->force) { + fprintf(fp, "%%EPOCH%%\n" + "1\n\n"); + } if(info->url) { fprintf(fp, "%%URL%%\n" "%s\n\n", info->url); -- cgit v1.2.3-24-g4f1b