pledge textproc/grepcidr, suggested by/ok job@

This commit is contained in:
sthen 2023-01-25 18:00:03 +00:00
parent 875ff3a029
commit 6cd3699a49
2 changed files with 34 additions and 1 deletions

View File

@ -3,7 +3,7 @@ COMMENT= filter files for IP address matches
# note there's also a "grepcidr-2" fork; this port is for the original
# version which is still developed by the original author.
DISTNAME= grepcidr-2.0
REVISION= 0
REVISION= 1
CATEGORIES= textproc net

View File

@ -0,0 +1,33 @@
Index: grepcidr.c
--- grepcidr.c.orig
+++ grepcidr.c
@@ -580,6 +580,12 @@ int main(int argc, char* argv[])
char* pat_strings = NULL; /* pattern strings on command line */
int foundopt;
+ if (pledge("stdio rpath", NULL) == -1)
+ {
+ fprintf(stderr, "grepcidr: pledge()");
+ return EXIT_ERROR;
+ }
+
if ((CHAR_BIT != 8) || (sizeof(unsigned int) < 4) ||
(sizeof(struct in_addr) != 4) || (sizeof(struct in6_addr) != 16))
{
@@ -660,8 +666,15 @@ int main(int argc, char* argv[])
{ /* Search each specified file name, or just stdin */
const char* curfilename = NULL;
FILE* inp_stream;
- if (optind >= argc)
+ if (optind >= argc) {
inp_stream = stdin;
+
+ if (pledge("stdio", NULL) == -1)
+ {
+ fprintf(stderr, "grepcidr: pledge()");
+ return EXIT_ERROR;
+ }
+ }
else
{
/* One or more file names are specified on the command line */