OSDN Git Service

(split) LDP: Update draft
[linuxjm/LDP_man-pages.git] / draft / man3 / gets.3
index 2c372be..f7ca846 100644 (file)
@@ -1,5 +1,6 @@
 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
-.\" License.
+.\" %%%LICENSE_END
+.\"
 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
+.\" Modified Fri Sep  8 15:48:13 1995 by Andries Brouwer (aeb@cwi.nl)
+.\" Modified 2013-12-31, David Malcolm <dmalcolm@redhat.com>
+.\"     Split gets(3) into its own page; fgetc() et al. move to fgetc(3)
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
 .\"
 .\" Japanese Version Copyright (c) 1997 IMAMURA Nobutaka
 .\"         all rights reserved.
 .\" Updated 1999-08-29, Kentaro Shirakata <argrath@ub32.org>
 .\" Updated 2001-11-02, Kentaro Shirakata <argrath@ub32.org>
 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
 .\"
-.TH GETS 3  2008-08-06 "GNU" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O fgetc, fgets, getc, getchar, gets, ungetc \- input of characters and strings
-fgetc, fgets, getc, getchar, gets, ungetc \- Ê¸»ú¤Èʸ»úÎó¤ÎÆþÎÏ
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH GETS 3 2014\-01\-24 GNU "Linux Programmer's Manual"
+.SH 名前
+gets \- 標準入力からの文字列を取得する (非推奨)
+.SH 書式
 .nf
-.B #include <stdio.h>
+\fB#include <stdio.h>\fP
 .sp
-.BI "int fgetc(FILE *" stream );
-
-.BI "char *fgets(char *" "s" ", int " "size" ", FILE *" "stream" );
-
-.BI "int getc(FILE *" stream );
+\fBchar *gets(char *\fP\fIs\fP\fB);\fP
+.fi
+.SH 説明
+\fIこの関数は使用しないこと\fP。
 
-.B "int getchar(void);"
+\fBgets\fP()  は、改行文字か \fBEOF\fP までの 1行を \fIstdin\fP から読み込み \fIs\fP が指すバッファに格納する
+(末尾の改行文字や \fBEOF\fP は NULL バイト (\(aq\e0\(aq) に置き換えられる)。 バッファオーバーランのチェックは行われない
+(下記の「バグ」を参照)。
+.SH 返り値
+\fBgets\fP()  returns \fIs\fP on success, and NULL on error or when end of file
+occurs while no characters have been read.  However, given the lack of
+buffer overrun checking, there can be no guarantees that the function will
+even return.
+.SH 準拠
+C89, C99, POSIX.1\-2001.
 
-.BI "char *gets(char *" "s" );
+LSB は \fBgets\fP() を非推奨としている。
+POSIX.1\-2008 では \fBgets\fP() に廃止予定の印が付けられている。
+ISO C11 では \fBgets\fP)() の規定が C 言語から削除されている。
+glibc バージョン 2.16 以降では、機能検査マシン \fB_ISOC11_SOURCE\fP が定義された
+場合、glibc ヘッダファイルでは \fBgets\fP)() の宣言が公開されない。
+.SH バグ
+\fBgets\fP()  は絶対に使用してはならない。 前もってデータを知ることなしに \fBgets\fP()  が何文字読むかを知ることはできず、
+\fBgets\fP()  がバッファの終わりを越えて書き込み続けるため、 \fBgets\fP()  を使うのは極めて危険である。
+これを利用してコンピュータのセキュリティが破られてきた。 代わりに \fBfgets\fP()  を使うこと。
 
-.BI "int ungetc(int " c ", FILE *" stream );
-.fi
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O .BR fgetc ()
-.\"O reads the next character from
-.\"O .I stream
-.\"O and returns it as an
-.\"O .I unsigned char
-.\"O cast to an
-.\"O .IR int ,
-.\"O or
-.\"O .B EOF
-.\"O on end of file or error.
-.BR fgetc ()
-¤Ï¡¢
-.I stream
-¤«¤é¼¡¤Îʸ»ú¤ò
-.I unsigned char
-¤È¤·¤ÆÆɤߡ¢
-.I int
-¤Ë¥­¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤È¤Ê¤Ã¤¿¾ì¹ç¤Ï
-.B EOF
-¤òÊÖ¤¹¡£
-.PP
-.\"O .BR getc ()
-.\"O is equivalent to
-.\"O .BR fgetc ()
-.\"O except that it may be implemented as a macro which evaluates
-.\"O .I stream
-.\"O more than once.
-.BR getc ()
-¤Ï
-.BR fgetc ()
-¤ÈƱÍͤÀ¤¬¡¢
-.I stream
-¤òÊ£¿ô²óɾ²Á¤¹¤ë¥Þ¥¯¥í¤È¤·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-.PP
-.\"O .BR getchar ()
-.\"O is equivalent to
-.\"O .BI "getc(" stdin ) \fR.
-.BR getchar ()
-¤Ï
-.BI "getc(" stdin ) \fR
-¤ÈƱ¤¸¤Ç¤¢¤ë¡£
-.PP
-.\"O .BR gets ()
-.\"O reads a line from
-.\"O .I stdin
-.\"O into the buffer pointed to by
-.\"O .I s
-.\"O until either a terminating newline or
-.\"O .BR EOF ,
-.\"O which it replaces with
-.\"O .BR \(aq\e0\(aq .
-.BR gets ()
-¤Ï¡¢²þ¹Ôʸ»ú¤«
-.B EOF
-¤Þ¤Ç¤Î 1¹Ô¤ò
-.I stdin
-¤«¤éÆɤ߹þ¤ß
-.I s
-¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë
-(ËöÈø¤Î²þ¹Ôʸ»ú¤ä
-.B EOF
-¤Ï
-.B \(aq\e0\(aq
-¤ËÃÖ¤­´¹¤¨¤é¤ì¤ë)¡£
-.\"O No check for buffer overrun is performed (see BUGS below).
-¥Ð¥Ã¥Õ¥¡¡¦¥ª¡¼¥Ð¡¼¥é¥ó¤Î¥Á¥§¥Ã¥¯¤Ï¹Ô¤ï¤ì¤Ê¤¤ (²¼µ­¤Î¡Ö¥Ð¥°¡×¤ò»²¾È)¡£
-.PP
-.\"O .BR fgets ()
-.\"O reads in at most one less than
-.\"O .I size
-.\"O characters from
-.\"O .I stream
-.\"O and stores them into the buffer pointed to by
-.\"O .IR s .
-.\"O Reading stops after an
-.\"O .B EOF
-.\"O or a newline.
-.\"O If a newline is read, it is stored into the buffer.
-.\"O A
-.\"O .B \(aq\e0\(aq
-.\"O is stored after the last character in the buffer.
-.BR fgets ()
-¤Ï
-.I stream
-¤«¤éºÇÂç¤Ç
-.IR size " - 1"
-¸Ä¤Îʸ»ú¤òÆɤ߹þ¤ß¡¢
-.I s
-¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£Æɤ߹þ¤ß¤Ï
-.B EOF
-¤Þ¤¿¤Ï²þ¹Ôʸ»ú¤òÆɤ߹þ¤ó¤À¸å¤ÇÄä»ß¤¹¤ë¡£
-Æɤ߹þ¤Þ¤ì¤¿²þ¹Ôʸ»ú¤Ï¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
-.B \(aq\e0\(aq
-ʸ»ú¤¬°ì¤Ä¥Ð¥Ã¥Õ¥¡¤ÎÃæ¤ÎºÇ¸å¤Îʸ»ú¤Î¸å¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¡£
-.PP
-.\"O .BR ungetc ()
-.\"O pushes
-.\"O .I c
-.\"O back to
-.\"O .IR stream ,
-.\"O cast to
-.\"O .IR "unsigned char" ,
-.\"O where it is available for subsequent read operations.
-.\"O Pushed-back characters
-.\"O will be returned in reverse order; only one pushback is guaranteed.
-.BR ungetc ()
-¤Ï¡¢¸å¤Î read Áàºî¤ÇÆɤá¤ë¤è¤¦¤Ë¡¢
-.I c
-¤ò
-.I "unsigned char"
-¤Ë¥­¥ã¥¹¥È¤·¤Æ
-.I stream
-¤Ë½ñ¤­Ì᤹¡£
-½ñ¤­Ìᤵ¤ì¤¿Ê¸»ú¤ÏµÕ½ç¤ËÌᤵ¤ì¤ë;
-½ñ¤­Ìᤷ¤È¤·¤ÆÊݾڤµ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢°ìʸ»ú¤À¤±¤Ç¤¢¤ë¡£
-.PP
-.\"O Calls to the functions described here can be mixed with each other and with
-.\"O calls to other input functions from the
-.\"O .I stdio
-.\"O library for the same input stream.
-¤³¤³¤Ç½Ò¤Ù¤¿´Ø¿ô¤ä
-.I stdio
-¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤òƱ¤¸ÆþÎÏ¥¹¥È¥ê¡¼¥à¤ËÂФ·¤Æ¸ß¤¤¤Ëº®¤¼¤Æ»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
-.PP
-.\"O For nonlocking counterparts, see
-.\"O .BR unlocked_stdio (3).
-¤³¤ì¤é¤Î½èÍý¤ò¥í¥Ã¥¯¤»¤º¤Ë¹Ô¤¤¤¿¤¤¤È¤­¤Ï¡¢
-.BR unlocked_stdio (3)
-¤ò»²¾È¤Î¤³¤È¡£
-.\"O .SH "RETURN VALUES"
-.SH ÊÖ¤êÃÍ
-.\"O .BR fgetc (),
-.\"O .BR getc ()
-.\"O and
-.\"O .BR getchar ()
-.\"O return the character read as an
-.\"O .I unsigned char
-.\"O cast to an
-.\"O .I int
-.\"O or
-.\"O .B EOF
-.\"O on end of file or error.
-.BR fgetc (),
-.BR getc (),
-.BR getchar ()
-¤Ï¡¢Ê¸»ú¤ò
-.I unsigned char
-¤È¤·¤ÆÆɤó¤Ç
-.I int
-¤Ë¥­¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤Î¾ì¹ç¤Ï
-.B EOF
-¤òÊÖ¤¹¡£
-.PP
-.\"O .BR gets ()
-.\"O and
-.\"O .BR fgets ()
-.\"O return
-.\"O .I s
-.\"O on success, and NULL
-.\"O on error or when end of file occurs while no characters have been read.
-.BR gets ()
-¤È
-.BR fgets ()
-¤Ï¡¢À®¸ù¤¹¤ë¤È
-.I s
-¤òÊÖ¤·¡¢¥¨¥é¡¼¤ä 1 Ê¸»ú¤âÆɤ߹þ¤ó¤Ç¤¤¤Ê¤¤¤Î¤Ë¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤Ë¤Ê¤Ã¤¿
-¾ì¹ç¤Ë NULL ¤òÊÖ¤¹¡£
-.PP
-.\"O .BR ungetc ()
-.\"O returns
-.\"O .I c
-.\"O on success, or
-.\"O .B EOF
-.\"O on error.
-.BR ungetc ()
-¤ÏÀ®¸ù¤¹¤ë¤È
-.I c
-¤òÊÖ¤·¡¢¥¨¥é¡¼¤Î¾ì¹ç¤Ï
-.B EOF
-¤òÊÖ¤¹¡£
-.\"O .SH "CONFORMS TO"
-.SH ½àµò
-C89, C99, POSIX.1-2001.
-.\"O LSB deprecates
-.\"O .BR gets ().
-LSB ¤Ç¤Ï
-.BR gets ()
-¤ÏÈó¿ä¾©¤Ç¤¢¤ë¡£
-.\"O POSIX.1-2008 removes the specification of
-.\"O .BR gets ().
-POSIX.1-2008 ¤Ç¤Ï
-.BR gets ()
-¤Î»ÅÍͤ¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
-.\"O .SH "BUGS"
-.SH ¥Ð¥°
-.\"O Never use
-.\"O .BR gets ().
-.\"O Because it is impossible to tell without knowing the data in advance how many
-.\"O characters
-.\"O .BR gets ()
-.\"O will read, and because
-.\"O .BR gets ()
-.\"O will continue to store characters past the end of the buffer,
-.\"O it is extremely dangerous to use.
-.\"O It has been used to break computer security.
-.\"O Use
-.\"O .BR fgets ()
-.\"O instead.
-.BR gets ()
-¤ÏÀäÂФ˻ÈÍѤ·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
-Á°¤â¤Ã¤Æ¥Ç¡¼¥¿¤òÃΤ뤳¤È¤Ê¤·¤Ë
-.BR gets ()
-¤¬²¿Ê¸»úÆɤफ¤òÃΤ뤳¤È¤Ï¤Ç¤­¤º¡¢
-.BR gets ()
-¤¬¥Ð¥Ã¥Õ¥¡¤Î½ª¤ï¤ê¤ò±Û¤¨¤Æ½ñ¤­¹þ¤ß³¤±¤ë¤¿¤á¡¢
-.BR gets ()
-¤ò»È¤¦¤Î¤Ï¶Ë¤á¤Æ´í¸±¤Ç¤¢¤ë¡£
-¤³¤ì¤òÍøÍѤ·¤Æ¥³¥ó¥Ô¥å¡¼¥¿¤Î¥»¥­¥å¥ê¥Æ¥£¤¬Çˤé¤ì¤Æ¤­¤¿¡£
-Âå¤ï¤ê¤Ë
-.BR fgets ()
-¤ò»È¤¦¤³¤È¡£
-.PP
-.\"O It is not advisable to mix calls to input functions from the
-.\"O .I stdio
-.\"O library with low-level calls to
-.\"O .BR read (2)
-.\"O for the file descriptor associated with the input stream; the results
-.\"O will be undefined and very probably not what you want.
-ÆþÎÏ¥¹¥È¥ê¡¼¥à¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ¡¢
-.I stdio
-¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤È¡¢Äã¥ì¥Ù¥ë¸Æ¤Ó½Ð¤·¤Î
-.BR read (2)
-¤òº®¤¼¤Æ¸Æ¤Ó½Ð¤¹»ö¤Ï´«¤á¤é¤ì¤Ê¤¤¡£
-·ë²Ì¤¬¤É¤¦¤Ê¤ë¤«¤Ïʬ¤«¤é¤º¡¢¤ª¤½¤é¤¯¤¢¤Ê¤¿¤Î
-˾¤ó¤Ç¤¤¤ë·ë²Ì¤Ë¤Ï¤Ê¤é¤Ê¤¤¤À¤í¤¦¡£
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR read (2),
-.BR write (2),
-.BR ferror (3),
-.BR fgetwc (3),
-.BR fgetws (3),
-.BR fopen (3),
-.BR fread (3),
-.BR fseek (3),
-.BR getline (3),
-.BR getwchar (3),
-.BR puts (3),
-.BR scanf (3),
-.BR ungetwc (3),
-.BR unlocked_stdio (3)
+For more information, see CWE\-242 (aka "Use of Inherently Dangerous
+Function") at http://cwe.mitre.org/data/definitions/242.html
+.SH 関連項目
+\fBread\fP(2), \fBwrite\fP(2), \fBferror\fP(3), \fBfgetc\fP(3), \fBfgets\fP(3),
+\fBfgetwc\fP(3), \fBfgetws\fP(3), \fBfopen\fP(3), \fBfread\fP(3), \fBfseek\fP(3),
+\fBgetline\fP(3), \fBgetwchar\fP(3), \fBputs\fP(3), \fBscanf\fP(3), \fBungetwc\fP(3),
+\fBunlocked_stdio\fP(3), \fBfeature_test_macros\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.64 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。