diff options
author | sjg <sjg@FreeBSD.org> | 2015-05-27 01:19:58 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2015-05-27 01:19:58 +0000 |
commit | 65145fa4c81da358fcbc3b650156dab705dfa34e (patch) | |
tree | 55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.bin/elfdump | |
parent | 60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff) | |
parent | e6b664c390af88d4a87208bc042ce503da664c3b (diff) | |
download | FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz |
Merge sync of head
Diffstat (limited to 'usr.bin/elfdump')
-rw-r--r-- | usr.bin/elfdump/elfdump.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c index bf9b718..cd10ce3 100644 --- a/usr.bin/elfdump/elfdump.c +++ b/usr.bin/elfdump/elfdump.c @@ -29,12 +29,15 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> + +#include <sys/capsicum.h> #include <sys/elf32.h> #include <sys/elf64.h> #include <sys/endian.h> #include <sys/mman.h> #include <sys/stat.h> #include <err.h> +#include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <stddef.h> @@ -258,6 +261,7 @@ e_machines(u_int mach) case EM_386: return "EM_386"; case EM_68K: return "EM_68K"; case EM_88K: return "EM_88K"; + case EM_IAMCU: return "EM_IAMCU"; case EM_860: return "EM_860"; case EM_MIPS: return "EM_MIPS"; case EM_PPC: return "EM_PPC"; @@ -467,6 +471,7 @@ elf_get_shstrndx(Elf32_Ehdr *e, void *sh) int main(int ac, char **av) { + cap_rights_t rights; u_int64_t phoff; u_int64_t shoff; u_int64_t phentsize; @@ -527,6 +532,9 @@ main(int ac, char **av) case 'w': if ((out = fopen(optarg, "w")) == NULL) err(1, "%s", optarg); + cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE); + if (cap_rights_limit(fileno(out), &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for %s", optarg); break; case '?': default: @@ -539,6 +547,17 @@ main(int ac, char **av) if ((fd = open(*av, O_RDONLY)) < 0 || fstat(fd, &sb) < 0) err(1, "%s", *av); + cap_rights_init(&rights, CAP_MMAP_R); + if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for %s", *av); + close(STDIN_FILENO); + cap_rights_init(&rights, CAP_WRITE); + if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdout"); + if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stderr"); + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); e = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); if (e == MAP_FAILED) err(1, NULL); |