--- src/lib/libc/stdio/fgets.3 2003/06/17 04:26:45 1.2 +++ src/lib/libc/stdio/fgets.3 2004/06/08 00:29:03 1.3 @@ -35,7 +35,7 @@ .\" .\" @(#)fgets.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: src/lib/libc/stdio/fgets.3,v 1.6.2.7 2002/07/02 19:51:21 archie Exp $ -.\" $DragonFly: src/lib/libc/stdio/fgets.3,v 1.1 2003/06/16 04:33:17 dillon Exp $ +.\" $DragonFly$ .\" .Dd June 4, 1993 .Dt FGETS 3 @@ -79,7 +79,7 @@ with an infinite and a .Fa stream of -.Em stdin , +.Dv stdin , except that the newline character (if any) is not stored in the string. It is the caller's responsibility to ensure that the input line, if any, is sufficiently short to fit in the string. @@ -133,6 +133,16 @@ may also fail and set .Va errno for any of the errors specified for the routine .Xr getchar 3 . +.Sh SECURITY CONSIDERATIONS +The +.Fn gets +function cannot be used securely. +Because of its lack of bounds checking, +and the inability for the calling program +to reliably determine the length of the next incoming line, +the use of this function enables malicious users +to arbitrarily change a running program's functionality through +a buffer overflow attack. .Sh SEE ALSO .Xr feof 3 , .Xr ferror 3 , @@ -144,16 +154,3 @@ and .Fn gets conform to .St -isoC . -.Sh BUGS -Since it is usually impossible to ensure that the next input line -is less than some arbitrary length, and because overflowing the -input buffer is almost invariably a security violation, programs -should -.Em NEVER -use -.Fn gets . -The -.Fn gets -function -exists purely to conform to -.St -isoC .