LoginSignup
1
1

More than 5 years have passed since last update.

secureCoding > strncpy() > コピーすべきデータがなくなると、残りのバッファをnullバイトで埋め尽くすという仕様からくる性能上の問題もある

Last updated at Posted at 2015-04-28

引用: C/C++ セキュアコーディング 第2版 by Robert C. Seacordら

strncpy()には、コピーすべきデータがなくなると、残りのバッファをnullバイトで埋め尽くすという仕様からくる性能上の問題もある。


strncpy()以外の関数はどうなっているのだろうか疑問に思った。

http://ideone.com/qkKrFK
にてstrcpy()をしたところ、nullバイトで埋め尽くすのではないことがわかった。

strncpy()を頻繁に呼んでいて、かつコピー文字列が長いソフトになると性能上の問題がでるのだろう。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1