現象
_Sntscanf_s関数を呼び出すアプリケーションを実行すると、呼び出しは、 EOF(-1)の値を返す必要があります。10 企業 2015 LTSB の Windows でアプリケーションを実行するときは、挿入された null 文字は無視されます。EOF (-1)の値ではなく1の値が間違っているを受信するnumFieldsフィールドが発生します。
たとえば、この問題は、次の Visual C++ アプリケーションで発生します。
#include "stdafx.h"
#include "string.h"
#include "stdlib.h"
int main()
{
TCHAR szBuff[256];
double temp = 0;
wcscpy_s(szBuff, L"77777777");
// this should force the _sntscanf_s to return an EOF (-1) value
szBuff[0] = '\0';
int numFields = _sntscanf_s(szBuff, _countof(szBuff), _T("%lf"), &temp);
if (numFields == EOF)
{
printf("Correct Behavior!!!\r\n");
}
else
{
printf("BUG: _sntscanf_s failed to return EOF!!!\r\n");
}
return 0;
}
原因
この問題は、10 企業 2015 LTSB の Windows に含まれる Ucrtbase.dll ファイル内のcommon_vsscanf関数では、既知の問題が発生したために発生します。この問題は、全体のscanfファミリの関数に影響します。
-
_vsscanf_l
-
引き
-
_sscanf_l
-
sscanf
-
_vsscanf_s_l
-
vsscanf_s
-
_sscanfs_l
-
sscanf_s
-
_snscanf_l
-
_snscanf_s
-
_snscanf_s_l
-
_snscanf_s
-
_vswscanf_l
-
vswscanf
-
_swscanf_l
-
swscanf
-
_vswscanf_s_l
-
vswscanf_s
-
_wsscanfs_l
-
swscanf_s
-
_snwscanf_l
-
_snwscanf_s
-
_snwscanf_s_l
-
_snwscanf_s
解決策
この問題を解決するには、の更新のインストール サービスを提供、2018 年 5 月月 8 日-KB4103716 (OS ビルド 10240.17861)。