diff options
author | Yuri Pankov <ypankov@tintri.com> | 2022-09-27 00:40:03 +0200 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2022-10-09 15:57:00 -0500 |
commit | d687f445dcb8e0cd6caf81ea59a259f83ac93e2d (patch) | |
tree | 0905f9f68f39c824ca3e616ab1d39afeac6b04cf | |
parent | eca0273a3d9494e12a4d82943f1b2d701cde4489 (diff) | |
download | illumos-joyent-d687f445dcb8e0cd6caf81ea59a259f83ac93e2d.tar.gz |
15016 find_elf should cope with O_DIRECTORY absence
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Reviewed by: Jason King <jason.brian.king+illumos@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/tools/find_elf/find_elf.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr/src/tools/find_elf/find_elf.c b/usr/src/tools/find_elf/find_elf.c index 7c31ccc685..4ece9ac44a 100644 --- a/usr/src/tools/find_elf/find_elf.c +++ b/usr/src/tools/find_elf/find_elf.c @@ -229,7 +229,18 @@ process_arg(char *arg) err(EXIT_FAILURE, "not a file or directory: %s", arg); } +#ifndef O_DIRECTORY + struct stat tsb; + if (stat(dir, &tsb) == -1) { + err(EXIT_FAILURE, "failed to stat %s", dir); + } + if (!S_ISDIR(tsb.st_mode)) { + errx(EXIT_FAILURE, "not a directory: %s", dir); + } + rootfd = open(dir, O_RDONLY); +#else rootfd = open(dir, O_RDONLY|O_DIRECTORY); +#endif if (rootfd < 0) { err(EXIT_FAILURE, "%s", dir); } |