Fix WebRTC Win64 + BoringSSL build.
There were many size_t to int conversions. RAND_poll and RAND_seed no longer do anything in BoringSSL, so fix that one by removing it. Use a checked_cast for the remaining ones. BUG=chromium:429039 R=henrike@webrtc.org Review URL: https://webrtc-codereview.appspot.com/28909004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7655 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
dd43bbed8f
commit
d89b69aade
@ -47,36 +47,17 @@ class RandomGenerator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(SSL_USE_OPENSSL)
|
#if defined(SSL_USE_OPENSSL)
|
||||||
// The OpenSSL RNG. Need to make sure it doesn't run out of entropy.
|
// The OpenSSL RNG.
|
||||||
class SecureRandomGenerator : public RandomGenerator {
|
class SecureRandomGenerator : public RandomGenerator {
|
||||||
public:
|
public:
|
||||||
SecureRandomGenerator() : inited_(false) {
|
SecureRandomGenerator() {}
|
||||||
}
|
~SecureRandomGenerator() {}
|
||||||
~SecureRandomGenerator() {
|
|
||||||
}
|
|
||||||
virtual bool Init(const void* seed, size_t len) {
|
virtual bool Init(const void* seed, size_t len) {
|
||||||
// By default, seed from the system state.
|
|
||||||
if (!inited_) {
|
|
||||||
if (RAND_poll() <= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
inited_ = true;
|
|
||||||
}
|
|
||||||
// Allow app data to be mixed in, if provided.
|
|
||||||
if (seed) {
|
|
||||||
RAND_seed(seed, len);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool Generate(void* buf, size_t len) {
|
virtual bool Generate(void* buf, size_t len) {
|
||||||
if (!inited_ && !Init(NULL, 0)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0);
|
return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
bool inited_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif defined(SSL_USE_NSS_RNG)
|
#elif defined(SSL_USE_NSS_RNG)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "webrtc/base/common.h"
|
#include "webrtc/base/common.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/base/openssl.h"
|
#include "webrtc/base/openssl.h"
|
||||||
|
#include "webrtc/base/safe_conversions.h"
|
||||||
#include "webrtc/base/sslroots.h"
|
#include "webrtc/base/sslroots.h"
|
||||||
#include "webrtc/base/stringutils.h"
|
#include "webrtc/base/stringutils.h"
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ static int socket_write(BIO* b, const char* in, int inl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int socket_puts(BIO* b, const char* str) {
|
static int socket_puts(BIO* b, const char* str) {
|
||||||
return socket_write(b, str, strlen(str));
|
return socket_write(b, str, rtc::checked_cast<int>(strlen(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static long socket_ctrl(BIO* b, int cmd, long num, void* ptr) {
|
static long socket_ctrl(BIO* b, int cmd, long num, void* ptr) {
|
||||||
@ -448,7 +449,7 @@ OpenSSLAdapter::Send(const void* pv, size_t cb) {
|
|||||||
|
|
||||||
ssl_write_needs_read_ = false;
|
ssl_write_needs_read_ = false;
|
||||||
|
|
||||||
int code = SSL_write(ssl_, pv, cb);
|
int code = SSL_write(ssl_, pv, checked_cast<int>(cb));
|
||||||
switch (SSL_get_error(ssl_, code)) {
|
switch (SSL_get_error(ssl_, code)) {
|
||||||
case SSL_ERROR_NONE:
|
case SSL_ERROR_NONE:
|
||||||
//LOG(LS_INFO) << " -- success";
|
//LOG(LS_INFO) << " -- success";
|
||||||
@ -503,7 +504,7 @@ OpenSSLAdapter::Recv(void* pv, size_t cb) {
|
|||||||
|
|
||||||
ssl_read_needs_write_ = false;
|
ssl_read_needs_write_ = false;
|
||||||
|
|
||||||
int code = SSL_read(ssl_, pv, cb);
|
int code = SSL_read(ssl_, pv, checked_cast<int>(cb));
|
||||||
switch (SSL_get_error(ssl_, code)) {
|
switch (SSL_get_error(ssl_, code)) {
|
||||||
case SSL_ERROR_NONE:
|
case SSL_ERROR_NONE:
|
||||||
//LOG(LS_INFO) << " -- success";
|
//LOG(LS_INFO) << " -- success";
|
||||||
@ -843,7 +844,8 @@ bool OpenSSLAdapter::ConfigureTrustedRootCertificates(SSL_CTX* ctx) {
|
|||||||
for (int i = 0; i < ARRAY_SIZE(kSSLCertCertificateList); i++) {
|
for (int i = 0; i < ARRAY_SIZE(kSSLCertCertificateList); i++) {
|
||||||
const unsigned char* cert_buffer = kSSLCertCertificateList[i];
|
const unsigned char* cert_buffer = kSSLCertCertificateList[i];
|
||||||
size_t cert_buffer_len = kSSLCertCertificateSizeList[i];
|
size_t cert_buffer_len = kSSLCertCertificateSizeList[i];
|
||||||
X509* cert = d2i_X509(NULL, &cert_buffer, cert_buffer_len);
|
X509* cert = d2i_X509(NULL, &cert_buffer,
|
||||||
|
checked_cast<long>(cert_buffer_len));
|
||||||
if (cert) {
|
if (cert) {
|
||||||
int return_value = X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), cert);
|
int return_value = X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), cert);
|
||||||
if (return_value == 0) {
|
if (return_value == 0) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "webrtc/base/common.h"
|
#include "webrtc/base/common.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
|
#include "webrtc/base/safe_conversions.h"
|
||||||
#include "webrtc/base/stream.h"
|
#include "webrtc/base/stream.h"
|
||||||
#include "webrtc/base/openssl.h"
|
#include "webrtc/base/openssl.h"
|
||||||
#include "webrtc/base/openssladapter.h"
|
#include "webrtc/base/openssladapter.h"
|
||||||
@ -114,7 +115,7 @@ static int stream_read(BIO* b, char* out, int outl) {
|
|||||||
int error;
|
int error;
|
||||||
StreamResult result = stream->Read(out, outl, &read, &error);
|
StreamResult result = stream->Read(out, outl, &read, &error);
|
||||||
if (result == SR_SUCCESS) {
|
if (result == SR_SUCCESS) {
|
||||||
return read;
|
return checked_cast<int>(read);
|
||||||
} else if (result == SR_EOS) {
|
} else if (result == SR_EOS) {
|
||||||
b->num = 1;
|
b->num = 1;
|
||||||
} else if (result == SR_BLOCK) {
|
} else if (result == SR_BLOCK) {
|
||||||
@ -132,7 +133,7 @@ static int stream_write(BIO* b, const char* in, int inl) {
|
|||||||
int error;
|
int error;
|
||||||
StreamResult result = stream->Write(in, inl, &written, &error);
|
StreamResult result = stream->Write(in, inl, &written, &error);
|
||||||
if (result == SR_SUCCESS) {
|
if (result == SR_SUCCESS) {
|
||||||
return written;
|
return checked_cast<int>(written);
|
||||||
} else if (result == SR_BLOCK) {
|
} else if (result == SR_BLOCK) {
|
||||||
BIO_set_retry_write(b);
|
BIO_set_retry_write(b);
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ static int stream_write(BIO* b, const char* in, int inl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int stream_puts(BIO* b, const char* str) {
|
static int stream_puts(BIO* b, const char* str) {
|
||||||
return stream_write(b, str, strlen(str));
|
return stream_write(b, str, checked_cast<int>(strlen(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) {
|
static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) {
|
||||||
@ -364,7 +365,7 @@ StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len,
|
|||||||
|
|
||||||
ssl_write_needs_read_ = false;
|
ssl_write_needs_read_ = false;
|
||||||
|
|
||||||
int code = SSL_write(ssl_, data, data_len);
|
int code = SSL_write(ssl_, data, checked_cast<int>(data_len));
|
||||||
int ssl_error = SSL_get_error(ssl_, code);
|
int ssl_error = SSL_get_error(ssl_, code);
|
||||||
switch (ssl_error) {
|
switch (ssl_error) {
|
||||||
case SSL_ERROR_NONE:
|
case SSL_ERROR_NONE:
|
||||||
@ -425,7 +426,7 @@ StreamResult OpenSSLStreamAdapter::Read(void* data, size_t data_len,
|
|||||||
|
|
||||||
ssl_read_needs_write_ = false;
|
ssl_read_needs_write_ = false;
|
||||||
|
|
||||||
int code = SSL_read(ssl_, data, data_len);
|
int code = SSL_read(ssl_, data, checked_cast<int>(data_len));
|
||||||
int ssl_error = SSL_get_error(ssl_, code);
|
int ssl_error = SSL_get_error(ssl_, code);
|
||||||
switch (ssl_error) {
|
switch (ssl_error) {
|
||||||
case SSL_ERROR_NONE:
|
case SSL_ERROR_NONE:
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include "webrtc/base/compile_assert.h"
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user