mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 09:51:50 -05:00
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 <dan@archlinux.org>
This commit is contained in:
parent
bd08581d2e
commit
eedf4f4e63
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user