diff --git a/parse.c b/parse.c index d372401b7..623776c88 100644 --- a/parse.c +++ b/parse.c @@ -59,11 +59,22 @@ static char rcsid[] = "$Id$"; #include #include #include -#ifdef HAVE_DIRENT_H -#include +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) #else -#include -#endif /* HAVE_DIRENT_H */ +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif #include "sudo.h" #include "options.h" @@ -147,11 +158,7 @@ char *cmnd, *path; int plen; struct stat cst, pst; DIR *dirp; -#ifdef HAVE_DIRENT_H struct dirent *dent; -#else - struct direct *dent; -#endif /* HAVE_DIRENT_H */ char buf[MAXCOMMANDLENGTH+1]; if (stat(cmnd, &cst) < 0) @@ -171,7 +178,7 @@ char *cmnd, *path; while ((dent = readdir(dirp)) != NULL) { strcpy(buf, path); - strcat(buf, dent->d_name); + strcat(buf, NAMLEN(dent)); if (stat(buf, &pst) < 0) continue; if (cst.st_dev == pst.st_dev && cst.st_ino == pst.st_ino)