<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yohhoy</author_name>
  <author_url>https://blog.hatena.ne.jp/yohhoy/</author_url>
  <blog_title>yohhoyの日記</blog_title>
  <blog_url>https://yohhoy.hatenadiary.jp/</blog_url>
  <categories>
    <anon>C</anon>
  </categories>
  <description>C標準ライブラリが提供するstrncpy関数の仕様について。有限長バッファへ文字列を切り詰めてコピーする処理では、strncpy関数が用いられるケースが多い。strncpy関数の仕様として「コピー元srcの文字列長が指定長BUFSIZE以上のとき、コピー先dest末尾にはNUL終端文字が設定されない」ため、下記★のようにコピー先バッファ末尾へのNUL終端文字代入が必須となる。この'\0'代入を忘れると正しいNUL終端文字列を構成しないケースが発生し、文字列としてdestを扱うタイミングでバッファオーバーランを引き起こす。 #define BUFSIZE 128 char dest[BUFSIZ…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyohhoy.hatenadiary.jp%2Fentry%2F20161102%2Fp1&quot; title=&quot;strncpy関数仕様のナゾ - yohhoyの日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2016-11-02 00:00:00</published>
  <title>strncpy関数仕様のナゾ</title>
  <type>rich</type>
  <url>https://yohhoy.hatenadiary.jp/entry/20161102/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
