FreeBSD Bugzilla – Attachment 205441 Details for
Bug 238692
math/prng: depends on to-be-removed gets(3)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Rolls in own function to replace venerable gets()
patch-obsolete-gets (text/plain), 974 bytes, created by
Eygene Ryabinkin
on 2019-06-30 20:17:12 UTC
(
hide
)
Description:
Rolls in own function to replace venerable gets()
Filename:
MIME Type:
Creator:
Eygene Ryabinkin
Created:
2019-06-30 20:17:12 UTC
Size:
974 bytes
patch
obsolete
>--- 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); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 238692
: 205441