X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=release%2Fman3%2Fstrcat.3;h=700176f45a30f02b78afecac69703def13c5542a;hb=bb92023e2caf6dc30bd3a8f07877ec870c853e23;hp=15fff2f1a985a0d8a3250a0f5a2e0ecb58471ca1;hpb=4fa3e54b837e5814a4598ec901d77446bf5cb9b3;p=linuxjm%2FLDP_man-pages.git diff --git a/release/man3/strcat.3 b/release/man3/strcat.3 index 15fff2f1..700176f4 100644 --- a/release/man3/strcat.3 +++ b/release/man3/strcat.3 @@ -1,5 +1,6 @@ .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" +.\" %%%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. @@ -19,6 +20,7 @@ .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. +.\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code @@ -32,7 +34,7 @@ .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* -.TH STRCAT 3 2011\-09\-28 GNU "Linux Programmer's Manual" +.TH STRCAT 3 2012\-07\-19 GNU "Linux Programmer's Manual" .SH 名前 strcat, strncat \- 二つの文字列を連結する .SH 書式 @@ -44,21 +46,26 @@ strcat, strncat \- 二つの文字列を連結する \fBchar *strncat(char *\fP\fIdest\fP\fB, const char *\fP\fIsrc\fP\fB, size_t \fP\fIn\fP\fB);\fP .fi .SH 説明 -\fBstrcat\fP() 関数は、\fIdest\fP 文字列の後に \fIsrc\fP 文字列を付け加える。 その際に、\fIdest\fP の最後にある終端の -NULL バイト (\(aq\e0\(aq) は上書きされ、新たに生成された文字列の末尾に終端の NULL バイトが付与される。 二つの文字列 -\fIsrc\fP と \fIdest\fP は重なってはならない。 また、文字列 \fIdest\fP は、連結後の結果を格納するのに 十分な大きさでなければならない。 +The \fBstrcat\fP() function appends the \fIsrc\fP string to the \fIdest\fP string, +overwriting the terminating null byte (\(aq\e0\(aq) at the end of \fIdest\fP, +and then adds a terminating null byte. The strings may not overlap, and the +\fIdest\fP string must have enough space for the result. If \fIdest\fP is not +large enough, program behavior is unpredictable; \fIbuffer overruns are a +favorite avenue for attacking secure programs\fP. .PP \fBstrncat\fP() も同様だが、以下の点が異なる。 .IP * 3 -\fIsrc\fP のうち最大 \fIn\fP 文字が使用される。 +\fIsrc\fP のうち最大 \fIn\fP バイトが使用される。 .IP * -\fIsrc\fP が \fIn\fP 文字以上の場合、 \fIsrc\fP は NULL 終端されている必要はない。 +\fIsrc\fP が \fIn\fP バイト以上の場合、 +\fIsrc\fP は NULL 終端されている必要はない。 .PP \fBstrcat\fP() と同じく、\fIdest\fP に格納される結果の文字列は常に NULL 終端される。 .PP -\fIsrc\fP が \fIn\fP 文字以上の場合、 \fBstrncat\fP() は \fIdest\fP に \fIn+1\fP 文字を書き込む (\fIsrc\fP からの -\fIn\fP 文字と終端の NULL バイトである)。 したがって、\fIdest\fP の大きさは最低でも \fIstrlen(dest)+n+1\fP -でなければならない。 +\fIsrc\fP が \fIn\fP バイト以上の場合、 \fBstrncat\fP() は \fIdest\fP に \fIn+1\fP +バイトを書き込む (\fIsrc\fP からの \fIn\fP バイトと終端の NULL バイトである)。 +したがって、\fIdest\fP の大きさは最低でも \fIstrlen(dest)+n+1\fP でなければ +ならない。 \fBstrncat\fP() の簡単な実装は以下のような感じであろう: .in +4n @@ -82,6 +89,27 @@ strncat(char *dest, const char *src, size_t n) \fBstrcat\fP() 関数と \fBstrncat\fP() 関数は、結果としてできる文字列 \fIdest\fP へのポインタを返す。 .SH 準拠 SVr4, 4.3BSD, C89, C99. +.SH 注意 +Some systems (the BSDs, Solaris, and others) provide the following function: + + size_t strlcat(char *dest, const char *src, size_t size); + +.\" https://lwn.net/Articles/506530/ +This function appends the null\-terminated string \fIsrc\fP to the string +\fIdest\fP, copying at most \fIsize\-strlen(dest)\-1\fP from \fIsrc\fP, and adds a null +terminator to the result, \fIunless\fP \fIsize\fP is less than \fIstrlen(dest)\fP. +This function fixes the buffer overrun problem of \fBstrcat\fP(), but the +caller must still handle the possibility of data loss if \fIsize\fP is too +small. The function returns the length of the string \fBstrlcat\fP() tried to +create; if the return value is greater than or equal to \fIsize\fP, data loss +occurred. If data loss matters, the caller \fImust\fP either check the +arguments before the call, or test the function return value. \fBstrlcat\fP() +is not present in glibc and is not standardized by POSIX, but is available +on Linux via the \fIlibbsd\fP library. .SH 関連項目 \fBbcopy\fP(3), \fBmemccpy\fP(3), \fBmemcpy\fP(3), \fBstrcpy\fP(3), \fBstring\fP(3), \fBstrncpy\fP(3), \fBwcscat\fP(3), \fBwcsncat\fP(3) +.SH この文書について +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部 +である。プロジェクトの説明とバグ報告に関する情報は +http://www.kernel.org/doc/man\-pages/ に書かれている。