.\" 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.
.\"
.\" 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
.\" Modified Sat Jul 24 18:11:47 1993 by Rik Faith (faith@cs.unc.edu)
.\" 2007-06-15, Marc Boyer <marc.boyer@enseeiht.fr> + mtk
.\" Improve discussion of strncat().
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
.\"
.\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
.\" all rights reserved.
.\" Updated & Modified Fri Feb 18 00:30:00 JST 2005
.\" by Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated 2007-07-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.58
+.\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.TH STRCAT 3 2008-06-13 "GNU" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH ̾Á°
-.\"O strcat, strncat \- concatenate two strings
-strcat, strncat \- Æó¤Ä¤Îʸ»úÎó¤òÏ¢·ë¤¹¤ë
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH STRCAT 3 2014\-01\-20 GNU "Linux Programmer's Manual"
+.SH 名前
+strcat, strncat \- 二つの文字列を連結する
+.SH 書式
.nf
-.B #include <string.h>
+\fB#include <string.h>\fP
.sp
-.BI "char *strcat(char *" dest ", const char *" src );
+\fBchar *strcat(char *\fP\fIdest\fP\fB, const char *\fP\fIsrc\fP\fB);\fP
.sp
-.BI "char *strncat(char *" dest ", const char *" src ", size_t " n );
+\fBchar *strncat(char *\fP\fIdest\fP\fB, const char *\fP\fIsrc\fP\fB, size_t \fP\fIn\fP\fB);\fP
.fi
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The
-.\"O .BR strcat ()
-.\"O function appends the \fIsrc\fP string to the
-.\"O \fIdest\fP string, overwriting the null byte (\(aq\\0\(aq) at the end of
-.\"O \fIdest\fP, and then adds a terminating null byte.
-.\"O The strings may not overlap, and the \fIdest\fP string must have
-.\"O enough space for the result.
-.BR strcat ()
-´Ø¿ô¤Ï¡¢\fIdest\fP ʸ»úÎó¤Î¸å¤Ë \fIsrc\fP ʸ»úÎó¤òÉÕ¤±²Ã¤¨¤ë¡£
-¤½¤ÎºÝ¤Ë¡¢\fIdest\fP ¤ÎºÇ¸å¤Ë¤¢¤ë¥Ì¥ë¥Ð¥¤¥È (\(aq\\0\(aq) ¤Ï¾å½ñ¤¤µ¤ì¡¢
-¿·¤¿¤ËÀ¸À®¤µ¤ì¤¿Ê¸»úÎó¤ÎËöÈø¤Ë½ªÃ¼¤Î¥Ì¥ë¥Ð¥¤¥È¤¬ÉÕÍ¿¤µ¤ì¤ë¡£
-Æó¤Ä¤Îʸ»úÎó \fIsrc\fP ¤È \fIdest\fP ¤Ï½Å¤Ê¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
-¤Þ¤¿¡¢Ê¸»úÎó \fIdest\fP ¤Ï¡¢Ï¢·ë¸å¤Î·ë²Ì¤ò³ÊǼ¤¹¤ë¤Î¤Ë
-½½Ê¬¤ÊÂ礤µ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
+.SH 説明
+\fBstrcat\fP() 関数は、\fIdest\fP 文字列の後に \fIsrc\fP 文字列を付け加える。 その際に、\fIdest\fP
+の最後にある終端のヌルバイト (\(aq\e0\(aq) は上書きされ、新たに生成された文字列の末尾に終端のヌルバイトが付与される。 二つの文字列
+\fIsrc\fP と \fIdest\fP は重なってはならない。 また、文字列 \fIdest\fP は、連結後の結果を格納するのに 十分な大きさでなければならない。
+\fIdest\fP が十分な大きさでない場合、プログラムがどのような動作をするか分からない。
+バッファオーバーランはセキュアなプログラムを攻撃する際に好んで使われる方法である。
.PP
-.\"O The
-.\"O .BR strncat ()
-.\"O function is similar, except that
-.\"O .IP * 3
-.\"O it will use at most \fIn\fP characters from \fIsrc\fP; and
-.\"O .IP *
-.\"O \fIsrc\fP does not need to be null-terminated if it contains
-.\"O \fIn\fP or more characters.
-.BR strncat ()
-¤âƱÍͤÀ¤¬¡¢°Ê²¼¤ÎÅÀ¤¬°Û¤Ê¤ë¡£
+\fBstrncat\fP() も同様だが、以下の点が異なる。
.IP * 3
-\fIsrc\fP ¤Î¤¦¤ÁºÇÂç \fIn\fP ʸ»ú¤¬»ÈÍѤµ¤ì¤ë¡£
+\fIsrc\fP のうち最大 \fIn\fP バイトが使用される。
.IP *
-\fIsrc\fP ¤¬ \fIn\fP ʸ»ú°Ê¾å¤Î¾ì¹ç¡¢
-\fIsrc\fP ¤Ï¥Ì¥ë½ªÃ¼¤µ¤ì¤Æ¤¤¤ëɬÍפϤʤ¤¡£
+\fIsrc\fP が \fIn\fP バイト以上の場合、
+\fIsrc\fP はヌル終端されている必要はない。
.PP
-.\"O As with
-.\"O .BR strcat (),
-.\"O the resulting string in \fIdest\fP is always null-terminated.
-.BR strcat ()
-¤ÈƱ¤¸¤¯¡¢\fIdest\fP ¤Ë³ÊǼ¤µ¤ì¤ë·ë²Ì¤Îʸ»úÎó¤Ï¾ï¤Ë¥Ì¥ë½ªÃ¼¤µ¤ì¤ë¡£
+\fBstrcat\fP() と同じく、\fIdest\fP に格納される結果の文字列は常にヌル終端される。
.PP
-.\"O If \fIsrc\fP contains \fIn\fP or more characters,
-.\"O .BR strncat ()
-.\"O writes \fIn+1\fP characters to \fIdest\fP (\fIn\fP
-.\"O from \fIsrc\fP plus the terminating null byte).
-.\"O Therefore, the size of \fIdest\fP must be at least
-.\"O \fIstrlen(dest)+n+1\fP.
-\fIsrc\fP ¤¬ \fIn\fP ʸ»ú°Ê¾å¤Î¾ì¹ç¡¢
-.BR strncat ()
-¤Ï \fIdest\fP ¤Ë \fIn+1\fP ʸ»ú¤ò½ñ¤¹þ¤à
-(\fIsrc\fP ¤«¤é¤Î \fIn\fP ʸ»ú¤È½ªÃ¼¤Î¥Ì¥ë¥Ð¥¤¥È¤Ç¤¢¤ë)¡£
-¤·¤¿¤¬¤Ã¤Æ¡¢\fIdest\fP ¤ÎÂ礤µ¤ÏºÇÄã¤Ç¤â
-\fIstrlen(dest)+n+1\fP ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
+\fIsrc\fP が \fIn\fP バイト以上の場合、 \fBstrncat\fP() は \fIdest\fP に \fIn+1\fP
+バイトを書き込む (\fIsrc\fP からの \fIn\fP バイトと終端のヌルバイトである)。
+したがって、\fIdest\fP の大きさは最低でも \fIstrlen(dest)+n+1\fP でなければ
+ならない。
-.\"O A simple implementation of
-.\"O .BR strncat ()
-.\"O might be:
-.BR strncat ()
-¤Î´Êñ¤Ê¼ÂÁõ¤Ï°Ê²¼¤Î¤è¤¦¤Ê´¶¤¸¤Ç¤¢¤í¤¦:
+\fBstrncat\fP() の簡単な実装は以下のような感じであろう:
.in +4n
.nf
size_t dest_len = strlen(dest);
size_t i;
- for (i = 0 ; i < n && src[i] != \(aq\\0\(aq ; i++)
+ for (i = 0 ; i < n && src[i] != \(aq\e0\(aq ; i++)
dest[dest_len + i] = src[i];
- dest[dest_len + i] = \(aq\\0\(aq;
+ dest[dest_len + i] = \(aq\e0\(aq;
return dest;
}
.fi
.in
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O The
-.\"O .BR strcat ()
-.\"O and
-.\"O .BR strncat ()
-.\"O functions return a pointer to the resulting string \fIdest\fP.
-.BR strcat ()
-´Ø¿ô¤È
-.BR strncat ()
-´Ø¿ô¤Ï¡¢·ë²Ì¤È¤·¤Æ¤Ç¤¤ëʸ»úÎó
-\fIdest\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
+.SH 返り値
+\fBstrcat\fP() 関数と \fBstrncat\fP() 関数は、結果としてできる文字列 \fIdest\fP へのポインタを返す。
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+関数 \fBstrcat\fP() と \fBstrncat\fP() はスレッドセーフである。
+.SH 準拠
SVr4, 4.3BSD, C89, C99.
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR bcopy (3),
-.BR memccpy (3),
-.BR memcpy (3),
-.BR strcpy (3),
-.BR strncpy (3),
-.BR wcscat (3),
-.BR wcsncat (3)
+.SH 注意
+いくつかのシステム (BSD、Solaris など) では以下の関数が提供されている。
+
+ size_t strlcat(char *dest, const char *src, size_t size);
+
+.\" https://lwn.net/Articles/506530/
+この関数は、ヌル終端された文字列 \fIsrc\fP を文字列 \fIdest\fP に追加する。 具体例には、 \fIsize\fP が \fIstrlen(dest)\fP
+より大きい場合には最大で \fIsize\-strlen(dest)\-1\fP バイトを \fIsrc\fP からコピーし、 結果の末尾に終端のヌルバイトを追加する。
+この関数では \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)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。