diff --git a/validat1.cpp b/validat1.cpp index 25a0fa80..97b3e6ee 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -468,7 +468,7 @@ bool TestSecBlock() cout << "passed:"; cout << " Append word32" << endl; - //********** Append **********// + //********** Concatenate **********// try { @@ -555,7 +555,7 @@ bool TestSecBlock() a.Assign(str1, COUNTOF(str1)); b.Assign(str1, COUNTOF(str1)); - temp &= (a == b); + temp &= (a.operator==(b)); a.Assign(str3, COUNTOF(str3)); b.Assign(str3, COUNTOF(str3)); @@ -592,7 +592,7 @@ bool TestSecBlock() a.Assign(str1, COUNTOF(str1)); b.Assign(str1, COUNTOF(str1)); - temp &= (a == b); + temp &= (a.operator==(b)); a.Assign(str3, COUNTOF(str3)); b.Assign(str3, COUNTOF(str3)); @@ -861,12 +861,10 @@ bool TestRDRAND() } else cout << "passed:"; - - const std::streamsize oldp = cout.precision(6); - const std::ios::fmtflags oldf = cout.setf(std::ios::fixed, std::ios::floatfield); + + StreamState ss(cout); + cout << std::setiosflags(std::ios::fixed) << std::setprecision(6); cout << " Maurer Randomness Test returned value " << mv << endl; - cout.precision(oldp); - cout.setf(oldf, std::ios::floatfield); if (meter.GetTotalBytes() < SIZE) { @@ -934,12 +932,10 @@ bool TestRDSEED() } else cout << "passed:"; - - const std::streamsize oldp = cout.precision(6); - const std::ios::fmtflags oldf = cout.setf(std::ios::fixed, std::ios::floatfield); + + StreamState ss(cout); + cout << std::setiosflags(std::ios::fixed) << std::setprecision(6); cout << " Maurer Randomness Test returned value " << mv << endl; - cout.precision(oldp); - cout.setf(oldf, std::ios::floatfield); if (meter.GetTotalBytes() < SIZE) { diff --git a/validate.h b/validate.h index bb208675..485ef16c 100644 --- a/validate.h +++ b/validate.h @@ -2,6 +2,8 @@ #define CRYPTOPP_VALIDATE_H #include "cryptlib.h" +#include +#include bool ValidateAll(bool thorough); bool TestSettings(); @@ -87,12 +89,35 @@ bool TestSecBlock(); bool TestPolynomialMod2(); #endif -// Coverity findings +// Coverity finding template T StringToValue(const std::string& str); + +// Coverity finding template<> int StringToValue(const std::string& str); +// Coverity finding +class StreamState +{ +public: + StreamState(std::ostream& out) + : m_out(out), m_fmt(out.flags()), m_prec(out.precision()) + { + } + + ~StreamState() + { + m_out.precision(m_prec); + m_out.flags(m_fmt); + } + +private: + std::ostream& m_out; + std::ios_base::fmtflags m_fmt; + std::streamsize m_prec; +}; + // Functions that need a RNG; uses AES inf CFB mode with Seed. CryptoPP::RandomNumberGenerator & GlobalRNG();