diff options
author | tjr <tjr@FreeBSD.org> | 2003-01-30 23:32:53 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2003-01-30 23:32:53 +0000 |
commit | 46abb5f788156fbe8f24fcd57385003d5c305ac2 (patch) | |
tree | bde80eadfc5398ec895cf08cb8d69d3dac7bc429 /lib/libc/stdio/gets.c | |
parent | 20b194222d53bcea90114bac2461afd175b24cb3 (diff) | |
download | FreeBSD-src-46abb5f788156fbe8f24fcd57385003d5c305ac2.zip FreeBSD-src-46abb5f788156fbe8f24fcd57385003d5c305ac2.tar.gz |
Back out previous. Many people disagreed with removing the warning.
Diffstat (limited to 'lib/libc/stdio/gets.c')
-rw-r--r-- | lib/libc/stdio/gets.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c index 08a6c3c..e247271 100644 --- a/lib/libc/stdio/gets.c +++ b/lib/libc/stdio/gets.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93"; __FBSDID("$FreeBSD$"); #include "namespace.h" +#include <unistd.h> #include <stdio.h> #include <sys/cdefs.h> #include "un-namespace.h" @@ -55,9 +56,16 @@ gets(buf) { int c; char *s; + static int warned; + static char w[] = + "warning: this program uses gets(), which is unsafe.\n"; FLOCKFILE(stdin); ORIENT(stdin, -1); + if (!warned) { + (void) _write(STDERR_FILENO, w, sizeof(w) - 1); + warned = 1; + } for (s = buf; (c = __sgetc(stdin)) != '\n';) if (c == EOF) if (s == buf) { |