0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

secureCoding > strcpy_s > 問題点 > 領域を超えてコピーしようとすると例外が発生する

Last updated at Posted at 2015-04-27

10 million bugs in my code. @ nanorisさんのページにstrcpy_s使用上の注意が記載されている。

対策の部分を引用させていただく。

  1. strcpy_s の代わりに strncpy_s を使用する。
  1. コピー先の長さは \0 を含めた文字数を指定する。
  2. コピー元の長さは \0 を含めない文字数 sizeof(a)-1 を指定する。
  3. または _TRUNCATE を指定する。
  4. 必ず \0 終端になるのでメモリを初期化する必要がない。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?