disable locale::global(locale("")) to avoid a segfault in the UTF-8 locale. Index: src/pdfgrep.cc --- src/pdfgrep.cc.orig +++ src/pdfgrep.cc @@ -455,12 +455,18 @@ static void handle_poppler_errors(const string &msg, v int main(int argc, char** argv) { Options options; + + if (pledge("stdio rpath wpath cpath tty", NULL) == -1) { + fprintf (stderr, "pdfgrep: pledge\n"); + exit (1); + } + init_colors(options.outconf.colors); // Set locale to user-preference. If this locale is an UTF-8 locale, the // regex-functions regcomp/regexec become unicode aware, which means // e.g. that '.' will match a unicode character, not a single byte. - locale::global(locale("")); + // locale::global(locale("")); enum re_engine_type { RE_POSIX = 0, @@ -727,6 +733,11 @@ int main(int argc, char** argv) bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") && strcmp(getenv("TERM"), "dumb"); + if (pledge("stdio rpath wpath cpath", NULL) == -1) { + fprintf (stderr, "pdfgrep: pledge\n"); + exit (1); + } + options.outconf.color = use_colors == COLOR_ALWAYS || (use_colors == COLOR_AUTO && color_tty); @@ -770,6 +781,12 @@ int main(int argc, char** argv) char *limitstr = getenv("PDFGREP_CACHE_LIMIT"); unsigned int limit = limitstr ? strtoul(limitstr, NULL, 10) : 200; limit_cachesize(options.cache_directory.c_str(), limit); + } + } + if (!options.use_cache) { + if (pledge("stdio rpath", NULL) == -1) { + fprintf (stderr, "pdfgrep: pledge\n"); + exit (1); } }