Date: Sun, 1 Sep 2019 16:46:18 +0000 (UTC) From: Li-Wen Hsu <lwhsu@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r510709 - in head/math/prng: . files Message-ID: <201909011646.x81GkIpY016452@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); + } +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909011646.x81GkIpY016452>