svn commit: r510709 - in head/math/prng: . files
Li-Wen Hsu
lwhsu at FreeBSD.org
Sun Sep 1 16:46:19 UTC 2019
Author: lwhsu
Date: Sun Sep 1 16:46:18 2019
New Revision: 510709
URL: https://svnweb.freebsd.org/changeset/ports/510709
Log:
Add a patch to remove use of gets(3)
PR: 238692
Submitted by: rea
Reported by: emaste
Sponsored by: The FreeBSD Foundation
Added:
head/math/prng/files/
head/math/prng/files/patch-no-gets (contents, props changed)
Modified:
head/math/prng/Makefile
Modified: head/math/prng/Makefile
==============================================================================
--- head/math/prng/Makefile Sun Sep 1 16:42:05 2019 (r510708)
+++ head/math/prng/Makefile Sun Sep 1 16:46:18 2019 (r510709)
@@ -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/
Added: head/math/prng/files/patch-no-gets
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/math/prng/files/patch-no-gets Sun Sep 1 16:46:18 2019 (r510709)
@@ -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);
+ }
+
More information about the svn-ports-head
mailing list