Sintomi
Quando si esegue un'applicazione che chiama la funzione _sntscanf_s , la chiamata deve restituire un valore EOF(-1) . Tuttavia, quando si esegue l'applicazione su Windows 10 Enterprise 2015 LTSB, il carattere null inserito viene ignorato. In questo modo il campo numFields ricevere un valore errato di 1 anziché il valore EOF (-1) .
Questo problema si verifica ad esempio nell'applicazione Visual C++ seguente:
#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;
}
Causa
Questo problema si verifica a causa di un problema noto nella funzione common_vsscanf nel file incluso in Windows 10 Enterprise 2015 LTSB Ucrtbase.dll. Il problema riguarda la famiglia intera scanf di funzioni:
-
_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
Risoluzione
Per risolvere questo problema, installare manutenzione aggiornamento 8 maggio 2018-KB4103716 (OS Build 10240.17861).