From 6cd8c11ba5aec7332a34d8b201e2ef4a5d358f91 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 30 Sep 2016 13:50:59 +0000 Subject: [PATCH] primes: trivially capsicumize Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7982 --- usr.bin/primes/primes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr.bin/primes/primes.c b/usr.bin/primes/primes.c index a1c95c2a8a02..bd02e10a1073 100644 --- a/usr.bin/primes/primes.c +++ b/usr.bin/primes/primes.c @@ -61,6 +61,7 @@ static const char rcsid[] = * validation check: there are 664579 primes between 0 and 10^7 */ +#include #include #include #include @@ -70,6 +71,7 @@ static const char rcsid[] = #include #include #include +#include #include #include "primes.h" @@ -99,6 +101,12 @@ main(int argc, char *argv[]) int ch; char *p; + /* Cache NLS data, for strerror, for err(3), before cap_enter. */ + (void)catopen("libc", NL_CAT_LOCALE); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "cap_enter"); + while ((ch = getopt(argc, argv, "h")) != -1) switch (ch) { case 'h':