The existing code tries to only print content of non-empty files, but
does not check the target of an encountered symbolic link, which could
be even something else, e.g. a fifo. Add the missing check to the
motddir_filter function.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
#ifdef MOTDDIR_SUPPORT
static int motddir_filter(const struct dirent *d)
{
+ struct stat st;
size_t namesz;
#ifdef _DIRENT_HAVE_D_TYPE
strcmp(d->d_name + (namesz - MOTDDIR_EXTSIZ), MOTDDIR_EXT) != 0)
return 0;
+ if (stat(d->d_name, &st) < 0)
+ return 0;
+ if (!S_ISREG(st.st_mode) || st.st_size == 0)
+ return 0;
+
return 1; /* accept */
}