OSDN Git Service

(split) LDP: Translate some pages
[linuxjm/LDP_man-pages.git] / draft / man3 / strcat.3
index a4a4cde..0ae9dfd 100644 (file)
@@ -49,8 +49,8 @@ strcat, strncat \- 二つの文字列を連結する
 \fBstrcat\fP()  関数は、\fIdest\fP 文字列の後に \fIsrc\fP 文字列を付け加える。 その際に、\fIdest\fP の最後にある終端の
 NULL バイト (\(aq\e0\(aq)  は上書きされ、新たに生成された文字列の末尾に終端の NULL バイトが付与される。 二つの文字列
 \fIsrc\fP と \fIdest\fP は重なってはならない。 また、文字列 \fIdest\fP は、連結後の結果を格納するのに 十分な大きさでなければならない。
-\fIdest\fP
\81\8cå\8d\81å\88\86ã\81ªå¤§ã\81\8dã\81\95ã\81§ã\81ªã\81\84å ´å\90\88ã\80\81ã\83\97ã\83­ã\82°ã\83©ã\83 ã\81\8cã\81©ã\81®ã\82\88ã\81\86ã\81ªå\8b\95ä½\9cã\82\92ã\81\99ã\82\8bã\81\8bå\88\86ã\81\8bã\82\89ã\81ªã\81\84ã\80\82ã\83\90ã\83\83ã\83\95ã\82¡ã\82ªã\83¼ã\83\90ã\83¼ã\83©ã\83³ã\81¯ã\82»ã\82­ã\83¥ã\82¢ã\81ªã\83\97ã\83­ã\82°ã\83©ã\83 ã\82\92æ\94»æ\92\83ã\81\99ã\82\8bé\9a\9bã\81«å¥½ã\82\93ã\81§ä½¿ã\82\8fã\82\8cã\82\8bæ\96¹æ³\95ã\81§ã\81\82ã\82\8bã\80\82
+\fIdest\fP が十分な大きさでない場合、プログラムがどのような動作をするか分からない。
+バッファオーバーランはセキュアなプログラムを攻撃する際に好んで使われる方法である。
 .PP
 \fBstrncat\fP()  も同様だが、以下の点が異なる。
 .IP * 3
@@ -94,17 +94,13 @@ SVr4, 4.3BSD, C89, C99.
     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.
+この関数は、 NULL 終端された文字列 \fIsrc\fP を文字列 \fIdest\fP に追加する。 具体例には、 \fIsize\fP が
+\fIstrlen(dest)\fP より大きい場合には最大で \fIsize\-strlen(dest)\-1\fP バイトを \fIsrc\fP からコピーし、
+結果の末尾に終端の NULL バイトを追加する。 この関数では \fBstrcat\fP() のバッファオーバーランが発生するという問題が修正されているが、
+\fIsize\fP が小さすぎた場合にはデータが失われる問題には、 依然として呼び出し側で対処する必要がある。 この関数は \fBstrlcat\fP()
+が作成しようとした文字列の長さを返す。 返り値が \fIsize\fP 以上の場合、 データロスが発生している。 データロスが問題となる場合は、
+呼び出し側で、 呼び出し前に引き数をチェックするか、 この関数の返り値を検査するかのいずれかをしなければならない。 \fBstrlcat\fP() は
+glibc には存在せず、 POSIX による標準化もされていないが、 Linux では \fIlibbsd\fP ライブラリ経由で利用できる。
 .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)