diff options
author | lwhsu <lwhsu@FreeBSD.org> | 2019-09-02 00:46:18 +0800 |
---|---|---|
committer | lwhsu <lwhsu@FreeBSD.org> | 2019-09-02 00:46:18 +0800 |
commit | ef9dbba53d4292c724b764c83bfbfb6b18ba13d9 (patch) | |
tree | cfedd82a644eff413cd31131521fe2034bf2225c /math | |
parent | b1dc7856671b50c1e1afc3d219713c70eb47a324 (diff) | |
download | freebsd-ports-gnome-ef9dbba53d4292c724b764c83bfbfb6b18ba13d9.tar.gz freebsd-ports-gnome-ef9dbba53d4292c724b764c83bfbfb6b18ba13d9.tar.zst freebsd-ports-gnome-ef9dbba53d4292c724b764c83bfbfb6b18ba13d9.zip |
Add a patch to remove use of gets(3)
PR: 238692
Submitted by: rea
Reported by: emaste
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'math')
-rw-r--r-- | math/prng/Makefile | 2 | ||||
-rw-r--r-- | math/prng/files/patch-no-gets | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/math/prng/Makefile b/math/prng/Makefile index b08bf68ee3f6..4fb3212d8a5a 100644 --- a/math/prng/Makefile +++ b/math/prng/Makefile @@ -3,7 +3,7 @@ PORTNAME= prng DISTVERSION= 3.0.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= math MASTER_SITES= http://statistik.wu-wien.ac.at/software/prng/ diff --git a/math/prng/files/patch-no-gets b/math/prng/files/patch-no-gets new file mode 100644 index 000000000000..6f7a6f838b63 --- /dev/null +++ b/math/prng/files/patch-no-gets @@ -0,0 +1,48 @@ +--- examples/pairs.c.orig 2019-06-30 22:57:59.603524000 +0300 ++++ examples/pairs.c 2019-06-30 23:06:55.659597000 +0300 +@@ -54,6 +54,18 @@ + #include <string.h> + #include "prng.h" + ++static void ++safe_gets(char *buf, int size) ++{ ++ size_t len; ++ ++ if (fgets(buf, size, stdin) == NULL) ++ return; ++ len = strlen(buf); ++ if (len && buf[len - 1] == '\n') ++ buf[len - 1] = '\0'; ++} ++ + struct prng_struct *generator; + char outfile[200] = "pairs.out"; + FILE *out; +@@ -71,7 +83,7 @@ + else + { + printf("\nGenerator ? "); +- gets(input); ++ safe_gets(input, sizeof(input)); + g = prng_new(input); + } + +@@ -88,7 +100,7 @@ + { + npairs = 10000; + printf("\nHow many pairs [%d] ",npairs); +- gets(input); ++ safe_gets(input, sizeof(input)); + if (input[0] != 0 ) npairs = atoi(input); + } + +@@ -97,7 +109,7 @@ + else + { + printf("Output filename ('-' for stdout) ? [%s] ",outfile); +- gets(input); ++ safe_gets(input, sizeof(input)); + if (input[0] != 0 ) strncpy(outfile,input,100); + } + |