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 > strncpy()の代わり > strndup() > 標準だけど実装されていない

Last updated at Posted at 2015-04-29

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

動的メモリ割り当て関数 ISO/IEC TR 24731-2 [ISO/IEC TR 24731-2:2010]は、strncpy()の代替関数として使用可能な関数として、strndup()関数を定義している。


[SO](http://stackoverflow.com/questions/6062822/whats-wrong-with-strndup)

string.hにstrdnup()が見つからないよ、という質問。理由は以下のようだ。

by Mat
strndup is "standard", but that standard is not implemented widely (yet). It's been present in GLIBC as an extension for quite a while. (But +1 anyway, malloc + strcpy is a good workaround.)

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?