check_pkg_fast: check file type

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
Andrew Gregory 2014-06-26 12:19:09 -04:00 committed by Allan McRae
parent c3835c157a
commit 71da296d01
2 changed files with 13 additions and 4 deletions

View file

@ -210,14 +210,25 @@ int check_pkg_fast(alpm_pkg_t *pkg)
const alpm_file_t *file = filelist->files + i; const alpm_file_t *file = filelist->files + i;
struct stat st; struct stat st;
const char *path = file->name; 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); pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);
continue; continue;
} }
strcpy(filepath + rootlen, path); 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) { if(!config->quiet) {

View file

@ -10,5 +10,3 @@ self.args = "-Qk"
self.addrule("PACMAN_RETCODE=1") self.addrule("PACMAN_RETCODE=1")
self.addrule("PACMAN_OUTPUT=warning.*(File type mismatch)") self.addrule("PACMAN_OUTPUT=warning.*(File type mismatch)")
self.expectfailure = True