อาการ
เมื่อคุณเรียกใช้โปรแกรมประยุกต์ที่เรียกฟังก์ชัน_sntscanf_sการโทรส่งกลับค่าEOF(-1) อย่างไรก็ตาม เมื่อคุณเรียกใช้โปรแกรมประยุกต์บน Windows LTSB 2015 องค์กรของ 10 อักขระ null ดังกล่าวจะถูกละเว้นไป ซึ่งทำให้ฟิลด์numFieldsจะได้รับค่าความผิดพลาดของ1แทนค่าEOF (-1)
ตัวอย่างเช่น ปัญหานี้เกิดขึ้นในแอพลิเคชัน 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;
}
สาเหตุ
ปัญหานี้เกิดขึ้นเนื่องจากปัญหาทราบสาเหตุในฟังก์ชันcommon_vsscanfในแฟ้ม Ucrtbase.dll ที่รวมอยู่ใน Windows LTSB 2015 องค์กรของ 10 ปัญหานี้มีผลกระทบต่อครอบครัวทั้งscanfของฟังก์ชัน:
-
_vsscanf_l
-
vsscanf
-
_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
การแก้ปัญหา
เมื่อต้องการแก้ไขปัญหานี้ ให้บริการติดตั้งอัพเด 8 พฤษภาคม 2018 — KB4103716 (OS สร้าง 10240.17861)