- Add LICENSE (BSL) - Add CPE data - Remove STATIC option and always install the shared library; no reason not to. - Remove GCC option and use USES=compiler framework - Add FULL_DEBUG option to address CVE-2016-7420 and add a warning if trying to use it. It will allow the asserts to be enabled which could be a security risk. The standard DEBUG option is now safe to use. - Add SIMD option for i386 and amd64 - requires a recent clang or gcc - Don't install the cryptest binary; it is really only used for regression testing, so only build it for the TEST_TARGET. It is useless without the data files anyways. - Take maintainership - Bump PORTREVISON on dependent ports due to shared library bump PR: 215015 Reported by: <fcsk.aim@gmail.com> MFH: 2016Q4 Security: eab68cff-bc0c-11e6-b2ca-001b3856973b
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
This fixes a warning triggered by testing an unsigned parameter
|
|
against 0. The patch solves this by creating a different template
|
|
for signed case. (PR: 178827)
|
|
|
|
--- misc.h.orig 2016-10-10 23:49:54 UTC
|
|
+++ misc.h
|
|
@@ -529,8 +529,10 @@ inline bool SafeConvert(T1 from, T2 &to)
|
|
//! \param value the value to convert
|
|
//! \param base the base to use during the conversion
|
|
//! \returns the string representation of value in base.
|
|
+template<bool> struct IsUnsigned {};
|
|
+
|
|
template <class T>
|
|
-std::string IntToString(T value, unsigned int base = 10)
|
|
+std::string IntToStringImpl(T value, unsigned int base, IsUnsigned<true>)
|
|
{
|
|
// Hack... set the high bit for uppercase.
|
|
static const unsigned int HIGH_BIT = (1U << 31);
|
|
@@ -541,12 +543,6 @@ std::string IntToString(T value, unsigne
|
|
if (value == 0)
|
|
return "0";
|
|
|
|
- bool negate = false;
|
|
- if (value < 0)
|
|
- {
|
|
- negate = true;
|
|
- value = 0-value; // VC .NET does not like -a
|
|
- }
|
|
std::string result;
|
|
while (value > 0)
|
|
{
|
|
@@ -554,11 +550,30 @@ std::string IntToString(T value, unsigne
|
|
result = char((digit < 10 ? '0' : (CH - 10)) + digit) + result;
|
|
value /= base;
|
|
}
|
|
+ return result;
|
|
+}
|
|
+
|
|
+template <class T>
|
|
+std::string IntToStringImpl(T value, unsigned int base, IsUnsigned<false>)
|
|
+{
|
|
+ bool negate = false;
|
|
+ if (value < 0)
|
|
+ {
|
|
+ negate = true;
|
|
+ value = 0-value; // VC .NET does not like -a
|
|
+ }
|
|
+ std::string result = IntToStringImpl(value, base, IsUnsigned<true>());
|
|
if (negate)
|
|
result = "-" + result;
|
|
return result;
|
|
}
|
|
|
|
+template <class T>
|
|
+std::string IntToString(T value, unsigned int base = 10)
|
|
+{
|
|
+ return IntToStringImpl(value, base, IsUnsigned<(static_cast<T>(-1) > 0)>());
|
|
+}
|
|
+
|
|
//! \brief Converts an unsigned value to a string
|
|
//! \param value the value to convert
|
|
//! \param base the base to use during the conversion
|