libc: assume no union stack if fstatfs fails in readdir

The failure is not really expected, but should it happen it's better to
get some data.

Suggested by:	kib
This commit is contained in:
mjg 2020-01-17 14:40:09 +00:00
parent 152d94131e
commit 607838ec39

View File

@ -283,7 +283,7 @@ __opendir_common(int fd, int flags, bool use_current_pos)
DIR *dirp;
int incr;
int saved_errno;
int unionstack;
bool unionstack;
if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
return (NULL);
@ -310,15 +310,14 @@ __opendir_common(int fd, int flags, bool use_current_pos)
/*
* Determine whether this directory is the top of a union stack.
*/
unionstack = false;
if (flags & DTF_NODUP) {
struct statfs sfb;
if (_fstatfs(fd, &sfb) < 0)
goto fail;
unionstack = !strcmp(sfb.f_fstypename, "unionfs")
|| (sfb.f_flags & MNT_UNION);
} else {
unionstack = 0;
if (_fstatfs(fd, &sfb) == 0) {
unionstack = strcmp(sfb.f_fstypename, "unionfs") == 0 ||
(sfb.f_flags & MNT_UNION);
}
}
if (unionstack) {