Fix buck build for SSLContext
authorAaron Balsara <abalsara@fb.com>
Fri, 15 Jan 2016 20:02:40 +0000 (12:02 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Fri, 15 Jan 2016 21:20:25 +0000 (13:20 -0800)
Summary: D2800746 broke buck with an unsigned/signed compare

Reviewed By: dkgi

Differential Revision: D2835102

fb-gh-sync-id: a0b8311b38a199e089d3ed5a69b12f8f8abe38b1

folly/io/async/SSLContext.cpp

index eb5f122a07eba55e02c8314f613cfb454b2249f7..4d2dfed0144f59c03e8bc7df09f56e42b3f57b80 100644 (file)
@@ -204,7 +204,7 @@ void SSLContext::loadCertificateFromBufferPEM(folly::StringPiece cert) {
   }
 
   int written = BIO_write(bio.get(), cert.data(), cert.size());
-  if (written != cert.size()) {
+  if (written <= 0 || static_cast<unsigned>(written) != cert.size()) {
     throw std::runtime_error("BIO_write: " + getErrors());
   }
 
@@ -244,7 +244,7 @@ void SSLContext::loadPrivateKeyFromBufferPEM(folly::StringPiece pkey) {
   }
 
   int written = BIO_write(bio.get(), pkey.data(), pkey.size());
-  if (written != pkey.size()) {
+  if (written <= 0 || static_cast<unsigned>(written) != pkey.size()) {
     throw std::runtime_error("BIO_write: " + getErrors());
   }