Ensures to call lstat_ex() only on regular files.

This commit is contained in:
Andrea Mazzoleni 2014-10-01 21:44:35 +02:00
parent 524360d8c2
commit c513af08ff
5 changed files with 57 additions and 17 deletions

View file

@ -67,6 +67,17 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
#if HAVE_STRUCT_DIRENT_D_STAT
/* convert dirent to lstat result */
dirent_lstat(dd, &st);
/* if the st_mode field is missing, takes care to fill it using normal lstat() */
/* at now this can happen only in Windows */
if (st.st_mode == 0) {
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
}
#else
/* get lstat info about the file */
if (lstat(path_next, &st) != 0) {