From 71da296d01ee564d39012415d7e1981c42723648 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Thu, 26 Jun 2014 12:19:09 -0400 Subject: check_pkg_fast: check file type Signed-off-by: Andrew Gregory --- src/pacman/check.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pacman/check.c b/src/pacman/check.c index 60a038a1..7109c7a8 100644 --- a/src/pacman/check.c +++ b/src/pacman/check.c @@ -210,14 +210,25 @@ int check_pkg_fast(alpm_pkg_t *pkg) const alpm_file_t *file = filelist->files + i; struct stat st; const char *path = file->name; + size_t plen = strlen(path); - if(rootlen + 1 + strlen(path) > PATH_MAX) { + if(rootlen + 1 + plen > PATH_MAX) { pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path); continue; } strcpy(filepath + rootlen, path); - errors += check_file_exists(pkgname, filepath, &st); + if(check_file_exists(pkgname, filepath, &st) == 0) { + int expect_dir = path[plen - 1] == '/' ? 1 : 0; + int is_dir = S_ISDIR(st.st_mode) ? 1 : 0; + if(expect_dir != is_dir) { + pm_printf(ALPM_LOG_WARNING, _("%s: %s (File type mismatch)\n"), + pkgname, filepath); + ++errors; + } + } else { + ++errors; + } } if(!config->quiet) { -- cgit v1.2.3-54-g00ecf