Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Utilisation de l’API interdite : le nom de la fonction n’est pas sécurisé et a été marqué comme déconseillé.
Cet avertissement indique qu’une fonction est utilisée alors qu’elle a été interdite et qu’il existe une version plus robuste ou plus sécurisée.
Notes
Une liste de toutes les fonctions interdites couvertes par cette erreur, pourquoi elles sont interdites et les remplacements recommandés sont disponibles après l’exemple suivant.
Nom de l’analyse du code : BANNED_API_USAGE
Exemple
Le code suivant génère cet avertissement :
void example_func(PSTR src)
{
char dst[100];
strcpy(dst, src);
}
Ce problème provient de l’utilisation de la fonction non sécurisée strcpy. strcpy ne vérifie pas si la mémoire tampon de destination est suffisamment grande pour s’adapter aux données sources. Pour résoudre ce problème, nous pouvons utiliser strcpy_s, le remplacement plus sûr de C++11 par cette fonction. strcpy_s a un troisième paramètre (la taille de la mémoire tampon de destination) pour vous assurer que de nombreux octets sont copiés. Par exemple, le code suivant est plus sûr :
void example_func(PSTR src)
{
char dst[100];
strcpy_s(dst, sizeof(dst), src);
}
Fonctions interdites
REMARQUE : Cette liste est activement mise à jour et améliorée
| API interdite | Remplacement(s) | Justification / Notes |
|---|---|---|
_fstrcat |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Implémentation de pointeur lointain 16 bits héritée |
_fstrcpy |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Implémentation de pointeur lointain 16 bits héritée |
_fstrncat |
StringCbCatN, , StringCbCatNExStringCchCatN, ,StringCchCatNEx |
Implémentation de pointeur lointain 16 bits héritée |
_fstrncpy |
strncpy, wcsncpy |
Implémentation de pointeur lointain 16 bits héritée |
_ftccat |
strcat, wcscat |
Implémentation de pointeur lointain 16 bits héritée |
_ftccpy |
strcpy, wcscpy |
Implémentation de pointeur lointain 16 bits héritée |
_ftcscat |
strcat, wcscat |
Implémentation de pointeur lointain 16 bits héritée |
_ftcscpy |
strcpy, wcscpy |
Implémentation de pointeur lointain 16 bits héritée |
_getts |
StringCbGets, , StringCbGetsExStringCchGets, , StringCchGetsExgets_s |
Aucune limite de taille sur les données |
_gettws |
gets_s |
Aucune limite de taille sur les données |
_getws |
_getws_s |
Aucune limite de taille sur les données |
_mbccat |
strcat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExstrlcat |
Aucune limite de taille sur les données |
_makepath |
_makepath_s |
Aucune limite de taille sur les données |
_mbscat |
_mbscat_s |
|
_snprintf |
_snprintf_s |
Ne se termine pas PAR NULL |
_sntprintf |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Ne se termine pas PAR NULL |
_sntscanf |
_snscanf_s |
Aucune longueur maximale |
_snwprintf |
_snwprintf_s, StringCbPrintf, , StringCbPrintf_lExStringCbPrintf_l, StringCbPrintfEx, , StringCchPrintf,StringCchPrintfEx |
Ne se termine pas PAR NULL |
_splitpath |
_splitpath_s |
Aucune vérification des limites |
_stprintf |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Détection d’erreurs limitée |
_stscanf |
sscanf_s (nécessite des modifications de chaîne de format) |
Aucune vérification des limites |
_tccat |
strcat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExstrlcat |
Aucune vérification des limites |
_tccpy |
strcpy_s, , StringCbCopy, StringCchCopyStringCbCopyEx, , StringCchCopyExstrlcpy |
Aucune vérification des limites |
_tcscat |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
_tcscpy |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Détection d’erreurs limitée |
_tcsncat |
StringCbLength, , StringCchLengthUnalignedStringCbLength, ,UnalignedStringCchLength |
Aucune longueur maximale |
_tcsncpy |
StringCbCopyN, , StringCbCopyNExStringCchCopyN, ,StringCchCopyNEx |
Détection d’erreurs limitée |
_tmakepath |
_makepath_s |
Aucune vérification des limites |
_tscanf |
scanf_s |
Aucune vérification des limites pour les sorties |
_tsplitpath |
splitpath_s, wsplitpath_s |
Aucune vérification des limites |
_vsnprintf |
_vsnprintf_s, , StringCchVPrintfStringCchVPrintf_l, , StringCchVPrintf_lExStringCchVPrintfEx |
Détection d’erreurs limitée |
_vsntprintf |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Détection d’erreurs limitée |
_vsnwprintf |
_vsnwprintf_s, , StringCbVPrintfStringCbVPrintf_l, , StringCbVPrintf_lExStringCbVPrintfEx |
Détection d’erreurs limitée |
_vstprintf |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrinfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucune longueur maximale |
_wmakepath |
_wmakepath_s |
Aucune vérification des limites |
_wsplitpath |
_wsplitpath_s |
Aucune vérification des limites |
OemToCharW |
WideCharToMultiByte |
Aucune vérification des limites |
StrCat |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
StrCatA |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
StrCatBuff |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Aucun arrêt NULL |
StrCatBuffA |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Aucun arrêt NULL |
StrCatBuffW |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Aucun arrêt NULL |
StrCatChainW |
StringCbCatEx, , StringCbCatNExStringCchCatEx, ,StringCchCatNEx |
Aucun arrêt NULL |
StrCatN |
StringCbCat, StringCbCatEx, , StringCbCatNExStringCbCatN, StringCchCat, StringCchCatEx, , StringCchCatN,StringCchCatNEx |
Aucune vérification des limites |
StrCatNA |
StringCbCat, StringCbCatEx, , StringCbCatNExStringCbCatN, StringCchCat, StringCchCatEx, , StringCchCatN,StringCchCatNEx |
Aucune vérification des limites |
StrCatNW |
StringCbCat, StringCbCatEx, , StringCbCatNExStringCbCatN, StringCchCat, StringCchCatEx, , StringCchCatN,StringCchCatNEx |
Aucune vérification des limites |
StrCatW |
StringCbCat, StringCbCatEx, , StringCbCatNExStringCbCatN, StringCchCat, StringCchCatEx, , StringCchCatN,StringCchCatNEx |
Aucune vérification des limites |
StrCpy |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
StrCpyA |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
StrCpyN |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Ne se termine pas PAR NULL |
StrCpyNA |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Ne se termine pas PAR NULL |
StrCpyNW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Vérification limitée des erreurs |
strcpyW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
StrCpyW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
StrNCat |
StringCbCatN, , StringCbCatNExStringCchCatN, ,StringCchCatNEx |
Détection d’erreurs limitée |
StrNCatA |
StringCbCatN, , StringCbCatNExStringCchCatN, ,StringCchCatNEx |
Détection d’erreurs limitée |
StrNCatW |
StringCbCatN, , StringCbCatNExStringCchCatN, ,StringCchCatNEx |
Détection d’erreurs limitée |
StrNCpy |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Ne se termine pas PAR NULL |
StrNCpyA |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Ne se termine pas PAR NULL |
StrNCpyW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Ne se termine pas PAR NULL |
gets |
gets_s, , fgets, StringCbGetsExStringCbGets, , StringCchGetsStringCchGetsEx |
Détection limitée des erreurs ; déconseillé par la norme C11 |
lstrcat |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcatA |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcatn |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcatnA |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcatnW |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcatW |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
lstrcpy |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
lstrcpyA |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
lstrcpyn |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Détection d’erreurs limitée |
lstrcpynA |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Détection d’erreurs limitée |
lstrcpynW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
lstrcpyW |
StringCbCopy, , StringCbCopyExStringCchCopy, ,StringCchCopyEx |
Aucune vérification des limites |
snscanf |
sscanf_s |
Aucune vérification des limites |
snwscanf |
swscanf_s |
Aucune vérification des limites |
sprintf |
sprintf_s |
Détection d’erreurs limitée |
sprintfA |
sprintf_s |
Aucune vérification des limites |
sprintfW |
swprintf_s |
Aucune vérification des limites |
lstrncat |
StringCbCat, , StringCbCatExStringCchCat, ,StringCchCatEx |
Détection d’erreurs limitée |
makepath |
||
nsprintf |
sprintf_s |
Aucune détection d’erreur ou vérification des limites |
strcat |
strcat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExstrlcat |
Détection d’erreurs limitée |
strcatA |
strcat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExstrlcat |
Détection d’erreurs limitée |
strcatW |
strcat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExstrlcat |
Détection d’erreurs limitée |
strcpy |
strcpy_s, , StringCbCopy, StringCchCopyStringCbCopyEx, , StringCchCopyExstrlcpy |
Aucune vérification des limites |
strcpyA |
strcpy_s, , StringCbCopy, StringCchCopyStringCbCopyEx, , StringCchCopyExstrlcpy |
Aucune vérification des limites |
strncat |
strncat_s, , StringCbCatN, StringCchCatNStringCbCatNEx, , StringCchCatNExstrlcat |
Détection d’erreurs limitée |
strncpy |
strncpy_s, , StringCbCopyN, StringCchCopyNStringCbCopyNEx, , StringCchCopyNExstrlcpy |
Détection d’erreurs limitée |
swprintf |
swprintf_sStringCbPrintf, , StringCbPrintf_lExStringCbPrintf_l, , StringCbPrintfStringCbPrintfEx |
Détection d’erreurs limitée |
ualstrcpyW |
strcpy_s, , StringCbCopy, StringCchCopyStringCbCopyEx, , StringCchCopyExstrlcpy |
Aucune vérification des limites |
vsnprintf |
vsnprintf_s, StringCbVPrintf, , StringCbVPrintf_lExStringCbVPrintf_l, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx,StringCchVPrintfEx |
Détection d’erreurs limitée |
vsprintf |
vsprintf_s, , StringCbVPrintf, StringCbVPrintf_lExStringCbVPrintf_l, , StringCchVPrintfStringCchVPrintfExStringCchVPrintf_lStringCchVPrintf_lExStringCbVPrintfExvasprintf |
Détection d’erreurs limitée |
vswprintf |
vswprintf_s |
|
wcscat |
wcscat_s, , StringCbCat, StringCchCatStringCbCatEx, , StringCchCatExwcslcat |
Détection d’erreurs limitée |
wcscpy |
wcscpy_s, , StringCbCopy, StringCchCopyStringCbCopyEx, , StringCchCopyExwcslcpy |
Aucune vérification des limites |
wcsncat |
wcsncat_s, wcslcat |
Détection d’erreurs limitée |
wcsncpy |
wcsncpy_s, , StringCbCopyN, StringCchCopyNStringCbCopyNEx, , StringCchCopyNExwcslcpy |
Détection d’erreurs limitée |
wnsprintf |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Aucun arrêt NULL |
wnsprintfA |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Aucun arrêt NULL |
wsprintf |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Aucun arrêt NULL |
wsprintfA |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Aucun arrêt NULL |
wsprintfW |
StringCbPrintf, , StringCbPrintf_l, StringCbPrintfExStringCbPrintf_lEx, , StringCchPrintfStringCchPrintfEx |
Aucun arrêt NULL |
wvnsprintf |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |
wvnsprintfA |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |
wvnsprintfW |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |
wvsprintf |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |
wvsprintfA |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |
wvsprintfW |
StringCbVPrintf, StringCbVPrintf_l, , StringCbVPrintfExStringCbVPrintf_lEx, StringCchVPrintf, StringCchVPrintf_l, , StringCchVPrintf_lEx,StringCchVPrintfEx |
Aucun arrêt NULL |