Fix FN for std::intmax_t passed as %ld, %lld into scanf

This commit is contained in:
Dmitry-Me 2017-11-20 23:07:37 +03:00
parent 7cf21f329a
commit 5869f6d989
2 changed files with 4 additions and 2 deletions

View File

@ -827,12 +827,12 @@ void CheckIO::checkFormatString(const Token * const tok,
if (argInfo.typeToken->str() != "long" || !argInfo.typeToken->isLong())
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, false);
else if (typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") ||
argInfo.typeToken->originalName() == "intmax_t")
typesMatch(argInfo.typeToken->originalName(), "intmax_t"))
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, false);
} else if (argInfo.typeToken->str() != "long" || argInfo.typeToken->isLong())
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, false);
else if (typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") ||
argInfo.typeToken->originalName() == "intmax_t")
typesMatch(argInfo.typeToken->originalName(), "intmax_t"))
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, false);
break;
case 'I':

View File

@ -1076,6 +1076,7 @@ private:
TEST_SCANF_WARN_AKA("%ld","long","size_t","unsigned long","unsigned long long");
TEST_SCANF_WARN_AKA("%ld","long","intmax_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%ld","long","std::ptrdiff_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%ld","long","std::intmax_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA_WIN64("%ld","long","std::intptr_t", "signed long long");
TEST_SCANF_WARN_AKA("%ld","long","std::uintptr_t", "unsigned long", "unsigned long long");
@ -1151,6 +1152,7 @@ private:
TEST_SCANF_WARN_AKA("%lld","long long","size_t", "unsigned long", "unsigned long long");
TEST_SCANF_WARN_AKA("%lld","long long","intmax_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%lld","long long","std::ptrdiff_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%lld","long long","std::intmax_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA_WIN32("%lld","long long","std::intptr_t", "signed long");
TEST_SCANF_WARN("%hu", "unsigned short", "bool");