tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man3 / gets.3
blobb77dad5c46838753bae903fe1800f3e64c76ea64
1 '\" t
2 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
7 .\" Modified Fri Sep  8 15:48:13 1995 by Andries Brouwer (aeb@cwi.nl)
8 .\" Modified 2013-12-31, David Malcolm <dmalcolm@redhat.com>
9 .\"     Split gets(3) into its own page; fgetc() et al. move to fgetc(3)
10 .TH gets 3 (date) "Linux man-pages (unreleased)"
11 .SH NAME
12 gets \- get a string from standard input (DEPRECATED)
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ", " \-lc )
16 .SH SYNOPSIS
17 .nf
18 .B #include <stdio.h>
19 .PP
20 .BI "[[deprecated]] char *gets(char *" "s" );
21 .fi
22 .SH DESCRIPTION
23 .IR "Never use this function" .
24 .PP
25 .BR gets ()
26 reads a line from
27 .I stdin
28 into the buffer pointed to by
29 .I s
30 until either a terminating newline or
31 .BR EOF ,
32 which it replaces with a null byte (\[aq]\e0\[aq]).
33 No check for buffer overrun is performed (see BUGS below).
34 .SH RETURN VALUE
35 .BR gets ()
36 returns
37 .I s
38 on success, and NULL
39 on error or when end of file occurs while no characters have been read.
40 However, given the lack of buffer overrun checking, there can be no
41 guarantees that the function will even return.
42 .SH ATTRIBUTES
43 For an explanation of the terms used in this section, see
44 .BR attributes (7).
45 .ad l
46 .nh
47 .TS
48 allbox;
49 lbx lb lb
50 l l l.
51 Interface       Attribute       Value
53 .BR gets ()
54 T}      Thread safety   MT-Safe
55 .TE
56 .hy
57 .ad
58 .sp 1
59 .SH STANDARDS
60 C99, POSIX.1-2001.
61 .PP
62 LSB deprecates
63 .BR gets ().
64 POSIX.1-2008 marks
65 .BR gets ()
66 obsolescent.
67 ISO C11 removes the specification of
68 .BR gets ()
69 from the C language, and since glibc 2.16,
70 glibc header files don't expose the function declaration if the
71 .B _ISOC11_SOURCE
72 feature test macro is defined.
73 .SH BUGS
74 Never use
75 .BR gets ().
76 Because it is impossible to tell without knowing the data in advance how many
77 characters
78 .BR gets ()
79 will read, and because
80 .BR gets ()
81 will continue to store characters past the end of the buffer,
82 it is extremely dangerous to use.
83 It has been used to break computer security.
84 Use
85 .BR fgets ()
86 instead.
87 .PP
88 For more information, see CWE-242 (aka "Use of Inherently Dangerous
89 Function") at
90 http://cwe.mitre.org/data/definitions/242.html
91 .SH SEE ALSO
92 .BR read (2),
93 .BR write (2),
94 .BR ferror (3),
95 .BR fgetc (3),
96 .BR fgets (3),
97 .BR fgetwc (3),
98 .BR fgetws (3),
99 .BR fopen (3),
100 .BR fread (3),
101 .BR fseek (3),
102 .BR getline (3),
103 .BR getwchar (3),
104 .BR puts (3),
105 .BR scanf (3),
106 .BR ungetwc (3),
107 .BR unlocked_stdio (3),
108 .BR feature_test_macros (7)