Sdílet prostřednictvím


Upozornění C28719

Zakázané použití rozhraní API: název funkce je nezabezpečený a je označený jako zastaralý.

Toto upozornění značí, že se používá funkce, která je zakázaná a má robustnější nebo bezpečnější náhradu.

Poznámky

Seznam všech zakázaných funkcí, na které se tato chyba vztahuje, proč jsou zakázány, a doporučené náhrady lze najít po následujícím příkladu.

Název analýzy kódu: BANNED_API_USAGE

Příklad

Následující kód vygeneruje toto upozornění:

void example_func(PSTR src) 
{ 
    char dst[100]; 
    strcpy(dst, src);
} 

Tento problém vychází z použití nebezpečné funkce strcpy. strcpy nekontroluje, jestli je cílová vyrovnávací paměť dostatečně velká, aby odpovídala zdrojovým datům.

K vyřešení tohoto problému můžeme použít strcpy_s, bezpečnější náhradu této funkce v jazyce C++11. strcpy_s má třetí parametr (velikost cílové vyrovnávací paměti), aby se zajistilo, že se zkopíruje pouze mnoho bajtů. Například následující kód je bezpečnější:

void example_func(PSTR src) 
{ 
    char dst[100]; 
    strcpy_s(dst, sizeof(dst), src); 
}

Zakázané funkce

POZNÁMKA: Tento seznam se aktivně aktualizuje a vylepšuje

Zakázané rozhraní API Náhrada/Náhrady Odůvodnění / poznámky
_fstrcat StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Implementace staršího 16bitového vzdáleného ukazatele
_fstrcpy StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Implementace staršího 16bitového ukazatele do dálky
_fstrncat StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx Implementace staršího 16bitového vzdáleného ukazatele
_fstrncpy strncpy, wcsncpy Implementace starých 16bitových farpointerů
_ftccat strcat, wcscat Implementace 16bitového staršího farového ukazatele
_ftccpy strcpy, wcscpy Implementace staršího 16bitového "far pointeru"
_ftcscat strcat, wcscat Implementace staršího 16bitového vzdáleného ukazatele
_ftcscpy strcpy, wcscpy Implementace zděděného 16bitového vzdáleného ukazatele
_getts StringCbGets, StringCbGetsEx, StringCchGets, StringCchGetsEx, gets_s Bez omezení velikosti u dat
_gettws gets_s Bez omezení velikosti u dat
_getws _getws_s Bez omezení velikosti u dat
_mbccat strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat Bez omezení velikosti u dat
_makepath _makepath_s Bez omezení velikosti u dat
_mbscat _mbscat_s
_snprintf _snprintf_s Neukončuje nulovým znakem
_sntprintf StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Není ukončeno znakem NULL
_sntscanf _snscanf_s Bez maximální délky
_snwprintf _snwprintf_s, StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Není ukončeno znakem NULL
_splitpath _splitpath_s Bez kontroly hranic
_stprintf StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Omezená detekce chyb
_stscanf sscanf_s (vyžaduje změny formátu řetězce) Bez kontroly hranic
_tccat strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat Bez kontroly hranic
_tccpy strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy Bez kontroly hranic
_tcscat StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
_tcscpy StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Omezená detekce chyb
_tcsncat StringCbLength, StringCchLength, UnalignedStringCbLength, UnalignedStringCchLength Bez maximální délky
_tcsncpy StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx Omezená detekce chyb
_tmakepath _makepath_s Bez kontroly hranic
_tscanf scanf_s Žádná kontrola hranic pro výstupy
_tsplitpath splitpath_s, wsplitpath_s Bez kontroly hranic
_vsnprintf _vsnprintf_s, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Omezená detekce chyb
_vsntprintf StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Omezená detekce chyb
_vsnwprintf _vsnwprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx Omezená detekce chyb
_vstprintf StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrinfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez maximální délky
_wmakepath _wmakepath_s Bez kontroly hranic
_wsplitpath _wsplitpath_s Bez kontroly hranic
OemToCharW WideCharToMultiByte Bez kontroly hranic
StrCat StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
StrCatA StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
StrCatBuff StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Bez ukončení s hodnotou NULL
StrCatBuffA StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Bez ukončení s hodnotou NULL
StrCatBuffW StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Bez ukončení s hodnotou NULL
StrCatChainW StringCbCatEx, StringCbCatNEx, StringCchCatEx, StringCchCatNEx Bez ukončení nulovým znakem
StrCatN StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx Bez kontroly hranic
StrCatNA StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx Bez kontroly hranic
StrCatNW StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx Bez kontroly hranic
StrCatW StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx Bez kontroly hranic
StrCpy StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
StrCpyA StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
StrCpyN StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Neukončuje nulovým znakem
StrCpyNA StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Neukončuje hodnotou NULL
StrCpyNW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Omezená kontrola chyb
strcpyW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
StrCpyW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
StrNCat StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx Omezená detekce chyb
StrNCatA StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx Omezená detekce chyb
StrNCatW StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx Omezená detekce chyb
StrNCpy StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Neukončuje nulovým znakem
StrNCpyA StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Není ukončeno znakem NULL
StrNCpyW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Není ukončeno znakem NULL
gets gets_s, fgets, StringCbGets, StringCbGetsEx, StringCchGets, StringCchGetsEx Omezená detekce chyb; zastaralé podle standardu C11
lstrcat StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcatA StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcatn StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcatnA StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcatnW StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcatW StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
lstrcpy StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
lstrcpyA StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
lstrcpyn StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Omezená detekce chyb
lstrcpynA StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Omezená detekce chyb
lstrcpynW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
lstrcpyW StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx Bez kontroly hranic
snscanf sscanf_s Bez kontroly hranic
snwscanf swscanf_s Bez kontroly hranic
sprintf sprintf_s Omezená detekce chyb
sprintfA sprintf_s Bez kontroly hranic
sprintfW swprintf_s Bez kontroly hranic
lstrncat StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx Omezená detekce chyb
makepath
nsprintf sprintf_s Žádná detekce chyb ani kontrola hranic
strcat strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat Omezená detekce chyb
strcatA strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat Omezená detekce chyb
strcatW strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat Omezená detekce chyb
strcpy strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy Bez kontroly hranic
strcpyA strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy Bez kontroly hranic
strncat strncat_s, StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx, strlcat Omezená detekce chyb
strncpy strncpy_s, StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx, strlcpy Omezená detekce chyb
swprintf swprintf_s StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintf, StringCbPrintfEx Omezená detekce chyb
ualstrcpyW strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy Bez kontroly hranic
vsnprintf vsnprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Omezená detekce chyb
vsprintf vsprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx, vasprintf Omezená detekce chyb
vswprintf vswprintf_s
wcscat wcscat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, wcslcat Omezená detekce chyb
wcscpy wcscpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, wcslcpy Bez kontroly hranic
wcsncat wcsncat_s, wcslcat Omezená detekce chyb
wcsncpy wcsncpy_s, StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx, wcslcpy Omezená detekce chyb
wnsprintf StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Bez ukončení pomocí NULL
wnsprintfA StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Bez ukončení s hodnotou NULL
wsprintf StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Bez ukončení s hodnotou NULL
wsprintfA StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Bez ukončení s hodnotou NULL
wsprintfW StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx Žádná NULL-terminace
wvnsprintf StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez ukončení s hodnotou NULL
wvnsprintfA StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez terminace NULL
wvnsprintfW StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Žádné ukončení hodnotou NULL
wvsprintf StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez zakončení NULL
wvsprintfA StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez ukončení s hodnotou NULL
wvsprintfW StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx Bez ukončení s hodnotou NULL