Waarschuwing C28719
Verboden API-gebruik: functienaam onveilig is en is afgeschaft.
Deze waarschuwing geeft aan dat een functie wordt gebruikt die is verboden en een krachtigere of veiligere vervanging heeft.
Opmerkingen
Een lijst met alle verboden functies die onder deze fout vallen, waarom ze worden verboden en aanbevolen vervangingen zijn te vinden na het volgende voorbeeld.
Naam van de code-analyse: BANNED_API_USAGE
Voorbeeld
Met de volgende code wordt deze waarschuwing gegenereerd:
void example_func(PSTR src)
{
char dst[100];
strcpy(dst, src);
}
Dit probleem komt voort uit het gebruik van de onveilige functie strcpy
.
strcpy
controleert niet of de doelbuffer groot genoeg is voor de brongegevens.
Om dit probleem op te lossen, kunnen we strcpy_s, de veiligere vervanging van C++11 voor deze functie gebruiken.
strcpy_s
heeft een derde parameter (de grootte van de doelbuffer) om ervoor te zorgen dat alleen veel bytes worden gekopieerd. De volgende code is bijvoorbeeld veiliger:
void example_func(PSTR src)
{
char dst[100];
strcpy_s(dst, sizeof(dst), src);
}
Verboden functies
OPMERKING: deze lijst wordt actief bijgewerkt en verbeterd
Verboden API | Vervanging(en) | Motivering / Notities |
---|---|---|
_fstrcat |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Verouderde 16-bits far pointer-implementatie |
_fstrcpy |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Verouderde 16-bits far pointer-implementatie |
_fstrncat |
StringCbCatN , StringCbCatNEx , StringCchCatN , StringCchCatNEx |
Verouderde 16-bits far pointer-implementatie |
_fstrncpy |
strncpy , wcsncpy |
Verouderde 16-bits far pointer-implementatie |
_ftccat |
strcat , wcscat |
Verouderde 16-bits far pointer-implementatie |
_ftccpy |
strcpy , wcscpy |
Verouderde 16-bits far pointer-implementatie |
_ftcscat |
strcat , wcscat |
Verouderde 16-bits far pointer-implementatie |
_ftcscpy |
strcpy , wcscpy |
Verouderde 16-bits far pointer-implementatie |
_getts |
StringCbGets , StringCbGetsEx , StringCchGets , StringCchGetsEx , gets_s |
Geen groottelimiet voor gegevens |
_gettws |
gets_s |
Geen groottelimiet voor gegevens |
_getws |
_getws_s |
Geen groottelimiet voor gegevens |
_mbccat |
strcat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , strlcat |
Geen groottelimiet voor gegevens |
_makepath |
_makepath_s |
Geen groottelimiet voor gegevens |
_mbscat |
_mbscat_s |
|
_snprintf |
_snprintf_s |
Eindigt niet met null-terminatie |
_sntprintf |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Eindigt niet met een NULL-teken |
_sntscanf |
_snscanf_s |
Geen maximumlengte |
_snwprintf |
_snwprintf_s , StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Eindigt niet met een NULL-karakter |
_splitpath |
_splitpath_s |
Geen grenzen controleren |
_stprintf |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Beperkte foutdetectie |
_stscanf |
sscanf_s (vereist opmaaktekenreekswijzigingen) |
Geen grenzen controleren |
_tccat |
strcat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , strlcat |
Geen grenzen controleren |
_tccpy |
strcpy_s , StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx , strlcpy |
Geen grenzen controleren |
_tcscat |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
_tcscpy |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Beperkte foutdetectie |
_tcsncat |
StringCbLength , StringCchLength , UnalignedStringCbLength , UnalignedStringCchLength |
Geen maximumlengte |
_tcsncpy |
StringCbCopyN , StringCbCopyNEx , StringCchCopyN , StringCchCopyNEx |
Beperkte foutdetectie |
_tmakepath |
_makepath_s |
Geen grenzen controleren |
_tscanf |
scanf_s |
Geen limietencontrole voor uitvoer |
_tsplitpath |
splitpath_s , wsplitpath_s |
Geen grenzen controleren |
_vsnprintf |
_vsnprintf_s , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Beperkte foutdetectie |
_vsntprintf |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Beperkte foutdetectie |
_vsnwprintf |
_vsnwprintf_s , StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx |
Beperkte foutdetectie |
_vstprintf |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrinfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen maximumlengte |
_wmakepath |
_wmakepath_s |
Geen grenzen controleren |
_wsplitpath |
_wsplitpath_s |
Geen grenzen controleren |
OemToCharW |
WideCharToMultiByte |
Geen grenzen controleren |
StrCat |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
StrCatA |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
StrCatBuff |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Geen NULL-beëindiging |
StrCatBuffA |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Geen NULL-beëindiging |
StrCatBuffW |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Geen NULL-beëindiging |
StrCatChainW |
StringCbCatEx , StringCbCatNEx , StringCchCatEx , StringCchCatNEx |
Geen NULL-terminatie |
StrCatN |
StringCbCat , StringCbCatEx , StringCbCatN , StringCbCatNEx , StringCchCat , StringCchCatEx , StringCchCatN , StringCchCatNEx |
Geen grenzen controleren |
StrCatNA |
StringCbCat , StringCbCatEx , StringCbCatN , StringCbCatNEx , StringCchCat , StringCchCatEx , StringCchCatN , StringCchCatNEx |
Geen grenzen controleren |
StrCatNW |
StringCbCat , StringCbCatEx , StringCbCatN , StringCbCatNEx , StringCchCat , StringCchCatEx , StringCchCatN , StringCchCatNEx |
Geen grenzen controleren |
StrCatW |
StringCbCat , StringCbCatEx , StringCbCatN , StringCbCatNEx , StringCchCat , StringCchCatEx , StringCchCatN , StringCchCatNEx |
Geen grenzen controleren |
StrCpy |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
StrCpyA |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
StrCpyN |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Eindigt niet met een NULL-teken |
StrCpyNA |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Wordt niet op NULL afgesloten |
StrCpyNW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Beperkte foutcontrole |
strcpyW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
StrCpyW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
StrNCat |
StringCbCatN , StringCbCatNEx , StringCchCatN , StringCchCatNEx |
Beperkte foutdetectie |
StrNCatA |
StringCbCatN , StringCbCatNEx , StringCchCatN , StringCchCatNEx |
Beperkte foutdetectie |
StrNCatW |
StringCbCatN , StringCbCatNEx , StringCchCatN , StringCchCatNEx |
Beperkte foutdetectie |
StrNCpy |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Wordt niet door NULL beëindigd |
StrNCpyA |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Eindigt niet met een NULL-karakter |
StrNCpyW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Eindigt niet met een NULL-terminatie |
gets |
gets_s , fgets , StringCbGets , StringCbGetsEx , StringCchGets , StringCchGetsEx |
Beperkte foutdetectie; afgeschaft volgens C11-standaard |
lstrcat |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcatA |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcatn |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcatnA |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcatnW |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcatW |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
lstrcpy |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
lstrcpyA |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
lstrcpyn |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Beperkte foutdetectie |
lstrcpynA |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Beperkte foutdetectie |
lstrcpynW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
lstrcpyW |
StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx |
Geen grenzen controleren |
snscanf |
sscanf_s |
Geen grenzen controleren |
snwscanf |
swscanf_s |
Geen grenzen controleren |
sprintf |
sprintf_s |
Beperkte foutdetectie |
sprintfA |
sprintf_s |
Geen grenzen controleren |
sprintfW |
swprintf_s |
Geen grenzen controleren |
lstrncat |
StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx |
Beperkte foutdetectie |
makepath |
||
nsprintf |
sprintf_s |
Geen foutdetectie of grenscontrole |
strcat |
strcat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , strlcat |
Beperkte foutdetectie |
strcatA |
strcat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , strlcat |
Beperkte foutdetectie |
strcatW |
strcat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , strlcat |
Beperkte foutdetectie |
strcpy |
strcpy_s , StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx , strlcpy |
Geen grenzen controleren |
strcpyA |
strcpy_s , StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx , strlcpy |
Geen grenzen controleren |
strncat |
strncat_s , StringCbCatN , StringCbCatNEx , StringCchCatN , StringCchCatNEx , strlcat |
Beperkte foutdetectie |
strncpy |
strncpy_s , StringCbCopyN , StringCbCopyNEx , StringCchCopyN , StringCchCopyNEx , strlcpy |
Beperkte foutdetectie |
swprintf |
swprintf_s
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintf , StringCbPrintfEx |
Beperkte foutdetectie |
ualstrcpyW |
strcpy_s , StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx , strlcpy |
Geen grenzen controleren |
vsnprintf |
vsnprintf_s , StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Beperkte foutdetectie |
vsprintf |
vsprintf_s , StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx , vasprintf |
Beperkte foutdetectie |
vswprintf |
vswprintf_s |
|
wcscat |
wcscat_s , StringCbCat , StringCbCatEx , StringCchCat , StringCchCatEx , wcslcat |
Beperkte foutdetectie |
wcscpy |
wcscpy_s , StringCbCopy , StringCbCopyEx , StringCchCopy , StringCchCopyEx , wcslcpy |
Geen grenzen controleren |
wcsncat |
wcsncat_s , wcslcat |
Beperkte foutdetectie |
wcsncpy |
wcsncpy_s , StringCbCopyN , StringCbCopyNEx , StringCchCopyN , StringCchCopyNEx , wcslcpy |
Beperkte foutdetectie |
wnsprintf |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Geen NULL-beëindiging |
wnsprintfA |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Geen null-terminatie |
wsprintf |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Geen nulbeëindiging |
wsprintfA |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Geen NULL-terminatie |
wsprintfW |
StringCbPrintf , StringCbPrintf_l , StringCbPrintf_lEx , StringCbPrintfEx , StringCchPrintf , StringCchPrintfEx |
Geen NULL-einde |
wvnsprintf |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-terminatie |
wvnsprintfA |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-beëindiging |
wvnsprintfW |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-beëindiging |
wvsprintf |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-beëindiging |
wvsprintfA |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-beëindiging |
wvsprintfW |
StringCbVPrintf , StringCbVPrintf_l , StringCbVPrintf_lEx , StringCbVPrintfEx , StringCchVPrintf , StringCchVPrintf_l , StringCchVPrintf_lEx , StringCchVPrintfEx |
Geen NULL-beëindiging |