]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/gets.3
fuse.4: ffix
[thirdparty/man-pages.git] / man3 / gets.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
c08df37a 24.\"
fea681da
MK
25.\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
26.\" Modified Fri Sep 8 15:48:13 1995 by Andries Brouwer (aeb@cwi.nl)
a5539262
MK
27.\" Modified 2013-12-31, David Malcolm <dmalcolm@redhat.com>
28.\" Split gets(3) into its own page; fgetc() et al. move to fgetc(3)
4b8c67d9 29.TH GETS 3 2017-09-15 "GNU" "Linux Programmer's Manual"
fea681da 30.SH NAME
d7f093e9 31gets \- get a string from standard input (DEPRECATED)
fea681da
MK
32.SH SYNOPSIS
33.nf
34.B #include <stdio.h>
68e4db0a 35.PP
fea681da 36.BI "char *gets(char *" "s" );
c8250206 37.fi
fea681da 38.SH DESCRIPTION
a5539262 39.IR "Never use this function" .
847e0d88 40.PP
c13182ef 41.BR gets ()
e1d6264d 42reads a line from
fea681da
MK
43.I stdin
44into the buffer pointed to by
45.I s
46until either a terminating newline or
47.BR EOF ,
31a6818e 48which it replaces with a null byte (\(aq\e0\(aq).
3d341b33 49No check for buffer overrun is performed (see BUGS below).
47297adb 50.SH RETURN VALUE
c13182ef 51.BR gets ()
7e2b0db3 52returns
fea681da 53.I s
8478ee02 54on success, and NULL
fea681da 55on error or when end of file occurs while no characters have been read.
beef2770
DM
56However, given the lack of buffer overrun checking, there can be no
57guarantees that the function will even return.
407633c3
MS
58.SH ATTRIBUTES
59For an explanation of the terms used in this section, see
60.BR attributes (7).
61.TS
62allbox;
63lb lb lb
64l l l.
65Interface Attribute Value
66T{
67.BR gets ()
68T} Thread safety MT-Safe
69.TE
847e0d88 70.sp 1
beef2770 71.SH CONFORMING TO
7e2b0db3 72C89, C99, POSIX.1-2001.
847e0d88 73.PP
fea681da 74LSB deprecates
63aa9df0 75.BR gets ().
1f04081f
MK
76POSIX.1-2008 marks
77.BR gets ()
78obsolescent.
5d83f9cd
MK
79ISO C11 removes the specification of
80.BR gets ()
81from the C language, and since version 2.16,
82glibc header files don't expose the function declaration if the
83.B _ISOC11_SOURCE
84feature test macro is defined.
fea681da
MK
85.SH BUGS
86Never use
63aa9df0 87.BR gets ().
fea681da
MK
88Because it is impossible to tell without knowing the data in advance how many
89characters
63aa9df0 90.BR gets ()
fea681da 91will read, and because
63aa9df0 92.BR gets ()
c13182ef
MK
93will continue to store characters past the end of the buffer,
94it is extremely dangerous to use.
95It has been used to break computer security.
96Use
63aa9df0 97.BR fgets ()
fea681da 98instead.
847e0d88 99.PP
beef2770
DM
100For more information, see CWE-242 (aka "Use of Inherently Dangerous
101Function") at
102http://cwe.mitre.org/data/definitions/242.html
47297adb 103.SH SEE ALSO
fea681da
MK
104.BR read (2),
105.BR write (2),
106.BR ferror (3),
a5539262 107.BR fgetc (3),
e0368396 108.BR fgets (3),
1709027c 109.BR fgetwc (3),
37f58312 110.BR fgetws (3),
fea681da
MK
111.BR fopen (3),
112.BR fread (3),
113.BR fseek (3),
bb47b54b 114.BR getline (3),
1709027c 115.BR getwchar (3),
fea681da
MK
116.BR puts (3),
117.BR scanf (3),
1709027c 118.BR ungetwc (3),
5d83f9cd
MK
119.BR unlocked_stdio (3),
120.BR feature_test_macros (7)