LoginSignup
1
1

More than 5 years have passed since last update.

strncpy() > null終端されないケース

Last updated at Posted at 2015-04-21

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

int main(void) {
   char buf[16];
   strncpy(buf, "0123456789abcdef", sizeof(a));
}

上記の例の場合、16文字目までnull終端文字が存在しない。結果としてbufもnull終端されないとのこと。

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