noloader / cryptopp-pem

PEM parsing of keys and parameters for Crypto++ project
42 stars 31 forks source link

In PEM_read, use of std::min with incompatible types leads to compilation error #8

Closed rbenet-lbo closed 5 years ago

rbenet-lbo commented 5 years ago

In PEM_read, there is a call to std::min with types (lword and size_t). Depending on the platform those types are of different size and lead to a compilation error.

Following patch works for me:

     // If the IV size is wrong, SetKeyWithIV will throw an exception.
-    const size_t size = (std::min)(hex.MaxRetrievable(), static_cast<size_t>(vsize));
+    const size_t size = (std::min)(hex.MaxRetrievable(), static_cast<lword>(vsize));
noloader commented 5 years ago

Thanks @rbenet-lbo.

Yeah, that looks about right. Do you want to clear it, or do you want me to do it?