Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Uso de API banido: nome da função é insegura e foi marcada como obsoleta.
Esse aviso indica que uma função está sendo usada que foi proibida e tem uma substituição mais robusta ou segura.
Observações
Uma lista de todas as funções proibidas cobertas por esse erro, por que elas são proibidas e as substituições recomendadas podem ser encontradas após o exemplo a seguir.
Nome da análise de código: BANNED_API_USAGE
Exemplo
O código a seguir gera este aviso:
void example_func(PSTR src)
{
char dst[100];
strcpy(dst, src);
}
Esse problema decorre do uso da função não segura strcpy. strcpy não verifica se o buffer de destino é grande o suficiente para ajustar os dados de origem.
Para corrigir esse problema, podemos usar strcpy_s, a substituição mais segura do C++11 para essa função. strcpy_s tem um terceiro parâmetro (o tamanho do buffer de destino) para garantir que apenas muitos bytes sejam copiados. Por exemplo, o código a seguir é mais seguro:
void example_func(PSTR src)
{
char dst[100];
strcpy_s(dst, sizeof(dst), src);
}
Funções proibidas
OBSERVAÇÃO: esta lista está sendo atualizada ativamente e aprimorada
| API proibida | Substituição(ões) | Racionalidade/Anotações |
|---|---|---|
_fstrcat |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Implementação de ponteiro distante herdado de 16 bits |
_fstrcpy |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Implementação de ponteiro distante herdado de 16 bits |
_fstrncat |
StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx |
Implementação de ponteiro distante herdado de 16 bits |
_fstrncpy |
strncpy, wcsncpy |
Implementação de ponteiro distante herdado de 16 bits |
_ftccat |
strcat, wcscat |
Implementação de ponteiro distante herdado de 16 bits |
_ftccpy |
strcpy, wcscpy |
Implementação de ponteiro distante herdado de 16 bits |
_ftcscat |
strcat, wcscat |
Implementação de ponteiro distante herdado de 16 bits |
_ftcscpy |
strcpy, wcscpy |
Implementação de ponteiro distante herdado de 16 bits |
_getts |
StringCbGets, StringCbGetsEx, StringCchGets, StringCchGetsEx, gets_s |
Nenhum limite de tamanho nos dados |
_gettws |
gets_s |
Nenhum limite de tamanho nos dados |
_getws |
_getws_s |
Nenhum limite de tamanho nos dados |
_mbccat |
strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat |
Nenhum limite de tamanho nos dados |
_makepath |
_makepath_s |
Nenhum limite de tamanho nos dados |
_mbscat |
_mbscat_s |
|
_snprintf |
_snprintf_s |
Não é terminado por NULL |
_sntprintf |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Não é terminado por NULL |
_sntscanf |
_snscanf_s |
Nenhum comprimento máximo |
_snwprintf |
_snwprintf_s, StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Não é terminado por NULL |
_splitpath |
_splitpath_s |
Nenhuma verificação de limites |
_stprintf |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Detecção de erro limitada |
_stscanf |
sscanf_s (requer alterações de cadeia de caracteres de formato) |
Nenhuma verificação de limites |
_tccat |
strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat |
Nenhuma verificação de limites |
_tccpy |
strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy |
Nenhuma verificação de limites |
_tcscat |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
_tcscpy |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Detecção de erro limitada |
_tcsncat |
StringCbLength, StringCchLength, UnalignedStringCbLength, UnalignedStringCchLength |
Nenhum comprimento máximo |
_tcsncpy |
StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx |
Detecção de erro limitada |
_tmakepath |
_makepath_s |
Nenhuma verificação de limites |
_tscanf |
scanf_s |
Nenhuma verificação de limites para saídas |
_tsplitpath |
splitpath_s, wsplitpath_s |
Nenhuma verificação de limites |
_vsnprintf |
_vsnprintf_s, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Detecção de erro limitada |
_vsntprintf |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Detecção de erro limitada |
_vsnwprintf |
_vsnwprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx |
Detecção de erro limitada |
_vstprintf |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrinfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Nenhum comprimento máximo |
_wmakepath |
_wmakepath_s |
Nenhuma verificação de limites |
_wsplitpath |
_wsplitpath_s |
Nenhuma verificação de limites |
OemToCharW |
WideCharToMultiByte |
Nenhuma verificação de limites |
StrCat |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
StrCatA |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
StrCatBuff |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Sem terminação NULL |
StrCatBuffA |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Sem terminação NULL |
StrCatBuffW |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Sem terminação NULL |
StrCatChainW |
StringCbCatEx, StringCbCatNEx, StringCchCatEx, StringCchCatNEx |
Sem terminação NULL |
StrCatN |
StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx |
Nenhuma verificação de limites |
StrCatNA |
StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx |
Nenhuma verificação de limites |
StrCatNW |
StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx |
Nenhuma verificação de limites |
StrCatW |
StringCbCat, StringCbCatEx, StringCbCatN, StringCbCatNEx, StringCchCat, StringCchCatEx, StringCchCatN, StringCchCatNEx |
Nenhuma verificação de limites |
StrCpy |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
StrCpyA |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
StrCpyN |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Não é terminado por NULL |
StrCpyNA |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Não é terminado por NULL |
StrCpyNW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Verificação de erro limitada |
strcpyW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
StrCpyW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
StrNCat |
StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx |
Detecção de erro limitada |
StrNCatA |
StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx |
Detecção de erro limitada |
StrNCatW |
StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx |
Detecção de erro limitada |
StrNCpy |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Não é terminado por NULL |
StrNCpyA |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Não é terminado por NULL |
StrNCpyW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Não é terminado por NULL |
gets |
gets_s, fgets, StringCbGets, StringCbGetsEx, StringCchGets, StringCchGetsEx |
Detecção de erro limitada; obsoleto pelo padrão C11 |
lstrcat |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcatA |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcatn |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcatnA |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcatnW |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcatW |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
lstrcpy |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
lstrcpyA |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
lstrcpyn |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Detecção de erro limitada |
lstrcpynA |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Detecção de erro limitada |
lstrcpynW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
lstrcpyW |
StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx |
Nenhuma verificação de limites |
snscanf |
sscanf_s |
Nenhuma verificação de limites |
snwscanf |
swscanf_s |
Nenhuma verificação de limites |
sprintf |
sprintf_s |
Detecção de erro limitada |
sprintfA |
sprintf_s |
Nenhuma verificação de limites |
sprintfW |
swprintf_s |
Nenhuma verificação de limites |
lstrncat |
StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx |
Detecção de erro limitada |
makepath |
||
nsprintf |
sprintf_s |
Nenhuma detecção de erro ou verificação de limites |
strcat |
strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat |
Detecção de erro limitada |
strcatA |
strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat |
Detecção de erro limitada |
strcatW |
strcat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, strlcat |
Detecção de erro limitada |
strcpy |
strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy |
Nenhuma verificação de limites |
strcpyA |
strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy |
Nenhuma verificação de limites |
strncat |
strncat_s, StringCbCatN, StringCbCatNEx, StringCchCatN, StringCchCatNEx, strlcat |
Detecção de erro limitada |
strncpy |
strncpy_s, StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx, strlcpy |
Detecção de erro limitada |
swprintf |
swprintf_sStringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintf, StringCbPrintfEx |
Detecção de erro limitada |
ualstrcpyW |
strcpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, strlcpy |
Nenhuma verificação de limites |
vsnprintf |
vsnprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Detecção de erro limitada |
vsprintf |
vsprintf_s, StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx, vasprintf |
Detecção de erro limitada |
vswprintf |
vswprintf_s |
|
wcscat |
wcscat_s, StringCbCat, StringCbCatEx, StringCchCat, StringCchCatEx, wcslcat |
Detecção de erro limitada |
wcscpy |
wcscpy_s, StringCbCopy, StringCbCopyEx, StringCchCopy, StringCchCopyEx, wcslcpy |
Nenhuma verificação de limites |
wcsncat |
wcsncat_s, wcslcat |
Detecção de erro limitada |
wcsncpy |
wcsncpy_s, StringCbCopyN, StringCbCopyNEx, StringCchCopyN, StringCchCopyNEx, wcslcpy |
Detecção de erro limitada |
wnsprintf |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Sem terminação NULL |
wnsprintfA |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Sem terminação NULL |
wsprintf |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Sem terminação NULL |
wsprintfA |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Sem terminação NULL |
wsprintfW |
StringCbPrintf, StringCbPrintf_l, StringCbPrintf_lEx, StringCbPrintfEx, StringCchPrintf, StringCchPrintfEx |
Sem terminação NULL |
wvnsprintf |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |
wvnsprintfA |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |
wvnsprintfW |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |
wvsprintf |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |
wvsprintfA |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |
wvsprintfW |
StringCbVPrintf, StringCbVPrintf_l, StringCbVPrintf_lEx, StringCbVPrintfEx, StringCchVPrintf, StringCchVPrintf_l, StringCchVPrintf_lEx, StringCchVPrintfEx |
Sem terminação NULL |