From 74c778c5f0f02d2a69935084b9f7fa4fd95ed27b Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 9 Nov 2017 00:26:07 +0300 Subject: [PATCH] Fix FN when unsigned ptrdiff_t is passed as %llu into scanf --- lib/checkio.cpp | 1 + test/testio.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index f9baa648a..b3de3a0b1 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -898,6 +898,7 @@ void CheckIO::checkFormatString(const Token * const tok, if (argInfo.typeToken->str() != "long" || !argInfo.typeToken->isLong()) invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); else if (typesMatch(argInfo.typeToken->originalName(), "size_t") || + typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") || argInfo.typeToken->originalName() == "uintmax_t") invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); } else if (argInfo.typeToken->str() != "long" || argInfo.typeToken->isLong()) diff --git a/test/testio.cpp b/test/testio.cpp index 9389a0108..a7e796ac0 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -1075,7 +1075,7 @@ private: TEST_SCANF_WARN_AKA("%llu","unsigned long long","size_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%llu","unsigned long long","ssize_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%llu","unsigned long long","ptrdiff_t", "signed long", "signed long long"); - TEST_SCANF_WARN_AKA_WIN32("%llu","unsigned long long","unsigned ptrdiff_t", "unsigned long"); + TEST_SCANF_WARN_AKA("%llu","unsigned long long","unsigned ptrdiff_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%llu","unsigned long long","intmax_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%llu","unsigned long long","uintmax_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%llu","unsigned long long","intptr_t", "signed long", "signed long long");