]>
Commit | Line | Data |
---|---|---|
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 | 31 | gets \- 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 | 42 | reads a line from |
fea681da MK |
43 | .I stdin |
44 | into the buffer pointed to by | |
45 | .I s | |
46 | until either a terminating newline or | |
47 | .BR EOF , | |
31a6818e | 48 | which it replaces with a null byte (\(aq\e0\(aq). |
3d341b33 | 49 | No check for buffer overrun is performed (see BUGS below). |
47297adb | 50 | .SH RETURN VALUE |
c13182ef | 51 | .BR gets () |
7e2b0db3 | 52 | returns |
fea681da | 53 | .I s |
8478ee02 | 54 | on success, and NULL |
fea681da | 55 | on error or when end of file occurs while no characters have been read. |
beef2770 DM |
56 | However, given the lack of buffer overrun checking, there can be no |
57 | guarantees that the function will even return. | |
407633c3 MS |
58 | .SH ATTRIBUTES |
59 | For an explanation of the terms used in this section, see | |
60 | .BR attributes (7). | |
61 | .TS | |
62 | allbox; | |
63 | lb lb lb | |
64 | l l l. | |
65 | Interface Attribute Value | |
66 | T{ | |
67 | .BR gets () | |
68 | T} Thread safety MT-Safe | |
69 | .TE | |
847e0d88 | 70 | .sp 1 |
beef2770 | 71 | .SH CONFORMING TO |
7e2b0db3 | 72 | C89, C99, POSIX.1-2001. |
847e0d88 | 73 | .PP |
fea681da | 74 | LSB deprecates |
63aa9df0 | 75 | .BR gets (). |
1f04081f MK |
76 | POSIX.1-2008 marks |
77 | .BR gets () | |
78 | obsolescent. | |
5d83f9cd MK |
79 | ISO C11 removes the specification of |
80 | .BR gets () | |
81 | from the C language, and since version 2.16, | |
82 | glibc header files don't expose the function declaration if the | |
83 | .B _ISOC11_SOURCE | |
84 | feature test macro is defined. | |
fea681da MK |
85 | .SH BUGS |
86 | Never use | |
63aa9df0 | 87 | .BR gets (). |
fea681da MK |
88 | Because it is impossible to tell without knowing the data in advance how many |
89 | characters | |
63aa9df0 | 90 | .BR gets () |
fea681da | 91 | will read, and because |
63aa9df0 | 92 | .BR gets () |
c13182ef MK |
93 | will continue to store characters past the end of the buffer, |
94 | it is extremely dangerous to use. | |
95 | It has been used to break computer security. | |
96 | Use | |
63aa9df0 | 97 | .BR fgets () |
fea681da | 98 | instead. |
847e0d88 | 99 | .PP |
beef2770 DM |
100 | For more information, see CWE-242 (aka "Use of Inherently Dangerous |
101 | Function") at | |
102 | http://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) |