summaryrefslogtreecommitdiff
path: root/src/mongo/util/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/net')
-rw-r--r--src/mongo/util/net/sock.cpp8
-rw-r--r--src/mongo/util/net/sock.h2
-rw-r--r--src/mongo/util/net/sock_test.cpp2
-rw-r--r--src/mongo/util/net/sockaddr.cpp2
-rw-r--r--src/mongo/util/net/ssl/detail/impl/engine_openssl.ipp10
-rw-r--r--src/mongo/util/net/ssl/impl/context_openssl.ipp12
-rw-r--r--src/mongo/util/net/ssl_manager_openssl.cpp26
7 files changed, 31 insertions, 31 deletions
diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp
index 6d7b2d1e8f7..bb616b4452e 100644
--- a/src/mongo/util/net/sock.cpp
+++ b/src/mongo/util/net/sock.cpp
@@ -190,7 +190,7 @@ Socket::Socket(int fd, const SockAddr& remote)
: _fd(fd),
_remote(remote),
_timeout(0),
- _lastValidityCheckAtSecs(time(0)),
+ _lastValidityCheckAtSecs(time(nullptr)),
_logLevel(logger::LogSeverity::Log()) {
_init();
if (fd >= 0) {
@@ -201,7 +201,7 @@ Socket::Socket(int fd, const SockAddr& remote)
Socket::Socket(double timeout, logger::LogSeverity ll) : _logLevel(ll) {
_fd = INVALID_SOCKET;
_timeout = timeout;
- _lastValidityCheckAtSecs = time(0);
+ _lastValidityCheckAtSecs = time(nullptr);
_init();
}
@@ -214,7 +214,7 @@ void Socket::_init() {
_bytesIn = 0;
_awaitingHandshake = true;
#ifdef MONGO_CONFIG_SSL
- _sslManager = 0;
+ _sslManager = nullptr;
#endif
}
@@ -612,7 +612,7 @@ bool Socket::isStillConnected() {
if (!isPollSupported())
return true; // nothing we can do
- time_t now = time(0);
+ time_t now = time(nullptr);
time_t idleTimeSecs = now - _lastValidityCheckAtSecs;
// Only check once every 5 secs
diff --git a/src/mongo/util/net/sock.h b/src/mongo/util/net/sock.h
index 561cd1cd9e4..a9edfc71de6 100644
--- a/src/mongo/util/net/sock.h
+++ b/src/mongo/util/net/sock.h
@@ -196,7 +196,7 @@ public:
*
* This function may throw SocketException.
*/
- SSLPeerInfo doSSLHandshake(const char* firstBytes = NULL, int len = 0);
+ SSLPeerInfo doSSLHandshake(const char* firstBytes = nullptr, int len = 0);
/**
* @return the time when the socket was opened.
diff --git a/src/mongo/util/net/sock_test.cpp b/src/mongo/util/net/sock_test.cpp
index 14cc5721e29..bb246175eef 100644
--- a/src/mongo/util/net/sock_test.cpp
+++ b/src/mongo/util/net/sock_test.cpp
@@ -210,7 +210,7 @@ public:
SocketFailPointTest()
: _failPoint(getGlobalFailPointRegistry()->getFailPoint(kSocketFailPointName)),
_sockets(socketPair(SOCK_STREAM)) {
- ASSERT_TRUE(_failPoint != NULL);
+ ASSERT_TRUE(_failPoint != nullptr);
ASSERT_TRUE(_sockets.first);
ASSERT_TRUE(_sockets.second);
}
diff --git a/src/mongo/util/net/sockaddr.cpp b/src/mongo/util/net/sockaddr.cpp
index be88e9c206e..9efa10ca409 100644
--- a/src/mongo/util/net/sockaddr.cpp
+++ b/src/mongo/util/net/sockaddr.cpp
@@ -280,7 +280,7 @@ std::string SockAddr::getAddr() const {
case AF_INET6: {
const int buflen = 128;
char buffer[buflen];
- int ret = getnameinfo(raw(), addressSize, buffer, buflen, NULL, 0, NI_NUMERICHOST);
+ int ret = getnameinfo(raw(), addressSize, buffer, buflen, nullptr, 0, NI_NUMERICHOST);
massert(
13082, str::stream() << "getnameinfo error " << getAddrInfoStrError(ret), ret == 0);
return buffer;
diff --git a/src/mongo/util/net/ssl/detail/impl/engine_openssl.ipp b/src/mongo/util/net/ssl/detail/impl/engine_openssl.ipp
index d143a358253..fc0ff1128b7 100644
--- a/src/mongo/util/net/ssl/detail/impl/engine_openssl.ipp
+++ b/src/mongo/util/net/ssl/detail/impl/engine_openssl.ipp
@@ -42,14 +42,14 @@ engine::engine(SSL_CTX* context, const std::string& remoteHostName)
::SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE);
::SSL_set_mode(ssl_, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
- ::BIO* int_bio = 0;
+ ::BIO* int_bio = nullptr;
::BIO_new_bio_pair(&int_bio, 0, &ext_bio_, 0);
::SSL_set_bio(ssl_, int_bio, int_bio);
}
engine::~engine() {
if (SSL_get_app_data(ssl_)) {
- SSL_set_app_data(ssl_, 0);
+ SSL_set_app_data(ssl_, nullptr);
}
::BIO_free(ext_bio_);
@@ -63,14 +63,14 @@ SSL* engine::native_handle() {
engine::want engine::handshake(stream_base::handshake_type type, asio::error_code& ec) {
return perform((type == asio::ssl::stream_base::client) ? &engine::do_connect
: &engine::do_accept,
- 0,
+ nullptr,
0,
ec,
- 0);
+ nullptr);
}
engine::want engine::shutdown(asio::error_code& ec) {
- return perform(&engine::do_shutdown, 0, 0, ec, 0);
+ return perform(&engine::do_shutdown, nullptr, 0, ec, nullptr);
}
engine::want engine::write(const asio::const_buffer& data,
diff --git a/src/mongo/util/net/ssl/impl/context_openssl.ipp b/src/mongo/util/net/ssl/impl/context_openssl.ipp
index b0b48910b4a..ef3ba9cb992 100644
--- a/src/mongo/util/net/ssl/impl/context_openssl.ipp
+++ b/src/mongo/util/net/ssl/impl/context_openssl.ipp
@@ -29,7 +29,7 @@
namespace asio {
namespace ssl {
-context::context(context::method m) : handle_(0) {
+context::context(context::method m) : handle_(nullptr) {
::ERR_clear_error();
switch (m) {
@@ -257,11 +257,11 @@ context::context(context::method m) : handle_(0) {
#endif // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
default:
- handle_ = ::SSL_CTX_new(0);
+ handle_ = ::SSL_CTX_new(nullptr);
break;
}
- if (handle_ == 0) {
+ if (handle_ == nullptr) {
asio::error_code ec(static_cast<int>(::ERR_get_error()), asio::error::get_ssl_category());
asio::detail::throw_error(ec, "context");
}
@@ -270,13 +270,13 @@ context::context(context::method m) : handle_(0) {
#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
context::context(context&& other) {
handle_ = other.handle_;
- other.handle_ = 0;
+ other.handle_ = nullptr;
}
context& context::operator=(context&& other) {
context tmp(ASIO_MOVE_CAST(context)(*this));
handle_ = other.handle_;
- other.handle_ = 0;
+ other.handle_ = nullptr;
return *this;
}
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
@@ -284,7 +284,7 @@ context& context::operator=(context&& other) {
context::~context() {
if (handle_) {
if (SSL_CTX_get_app_data(handle_)) {
- SSL_CTX_set_app_data(handle_, 0);
+ SSL_CTX_set_app_data(handle_, nullptr);
}
::SSL_CTX_free(handle_);
diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp
index 59695f00504..3c178b9f0b2 100644
--- a/src/mongo/util/net/ssl_manager_openssl.cpp
+++ b/src/mongo/util/net/ssl_manager_openssl.cpp
@@ -738,7 +738,7 @@ SSLConnectionOpenSSL::SSLConnectionOpenSSL(SSL_CTX* context,
ssl = SSL_new(context);
std::string sslErr =
- NULL != getSSLManager() ? getSSLManager()->getSSLErrorMessage(ERR_get_error()) : "";
+ nullptr != getSSLManager() ? getSSLManager()->getSSLErrorMessage(ERR_get_error()) : "";
massert(15861, "Error creating new SSL object " + sslErr, ssl);
BIO_new_bio_pair(&internalBIO, BUFFER_SIZE, &networkBIO, BUFFER_SIZE);
@@ -794,7 +794,7 @@ SSLManagerOpenSSL::SSLManagerOpenSSL(const SSLParams& params, bool isServer)
if (!clientPEM.empty()) {
if (!_parseAndValidateCertificate(
- clientPEM, clientPassword, &_sslConfiguration.clientSubjectName, NULL)) {
+ clientPEM, clientPassword, &_sslConfiguration.clientSubjectName, nullptr)) {
uasserted(16941, "ssl initialization problem");
}
}
@@ -1069,7 +1069,7 @@ bool SSLManagerOpenSSL::_parseAndValidateCertificate(const std::string& keyFile,
SSLX509Name* subjectName,
Date_t* serverCertificateExpirationDate) {
BIO* inBIO = BIO_new(BIO_s_file());
- if (inBIO == NULL) {
+ if (inBIO == nullptr) {
error() << "failed to allocate BIO object: " << getSSLErrorMessage(ERR_get_error());
return false;
}
@@ -1082,8 +1082,8 @@ bool SSLManagerOpenSSL::_parseAndValidateCertificate(const std::string& keyFile,
}
X509* x509 = PEM_read_bio_X509(
- inBIO, NULL, &SSLManagerOpenSSL::password_cb, static_cast<void*>(&keyPassword));
- if (x509 == NULL) {
+ inBIO, nullptr, &SSLManagerOpenSSL::password_cb, static_cast<void*>(&keyPassword));
+ if (x509 == nullptr) {
error() << "cannot retrieve certificate from keyfile: " << keyFile << ' '
<< getSSLErrorMessage(ERR_get_error());
return false;
@@ -1091,7 +1091,7 @@ bool SSLManagerOpenSSL::_parseAndValidateCertificate(const std::string& keyFile,
ON_BLOCK_EXIT([&] { X509_free(x509); });
*subjectName = getCertificateSubjectX509Name(x509);
- if (serverCertificateExpirationDate != NULL) {
+ if (serverCertificateExpirationDate != nullptr) {
unsigned long long notBeforeMillis = _convertASN1ToMillis(X509_get_notBefore(x509));
if (notBeforeMillis == 0) {
error() << "date conversion failed";
@@ -1166,7 +1166,7 @@ bool SSLManagerOpenSSL::_setupPEM(SSL_CTX* context,
Status SSLManagerOpenSSL::_setupCA(SSL_CTX* context, const std::string& caFile) {
// Set the list of CAs sent to clients
STACK_OF(X509_NAME)* certNames = SSL_load_client_CA_file(caFile.c_str());
- if (certNames == NULL) {
+ if (certNames == nullptr) {
return Status(ErrorCodes::InvalidSSLConfiguration,
str::stream() << "cannot read certificate authority file: " << caFile << " "
<< getSSLErrorMessage(ERR_get_error()));
@@ -1174,7 +1174,7 @@ Status SSLManagerOpenSSL::_setupCA(SSL_CTX* context, const std::string& caFile)
SSL_CTX_set_client_CA_list(context, certNames);
// Load trusted CA
- if (SSL_CTX_load_verify_locations(context, caFile.c_str(), NULL) != 1) {
+ if (SSL_CTX_load_verify_locations(context, caFile.c_str(), nullptr) != 1) {
return Status(ErrorCodes::InvalidSSLConfiguration,
str::stream() << "cannot read certificate authority file: " << caFile << " "
<< getSSLErrorMessage(ERR_get_error()));
@@ -1426,8 +1426,8 @@ bool SSLManagerOpenSSL::_doneWithSSLOp(SSLConnectionOpenSSL* conn, int status) {
}
SSLConnectionInterface* SSLManagerOpenSSL::connect(Socket* socket) {
- std::unique_ptr<SSLConnectionOpenSSL> sslConn =
- std::make_unique<SSLConnectionOpenSSL>(_clientContext.get(), socket, (const char*)NULL, 0);
+ std::unique_ptr<SSLConnectionOpenSSL> sslConn = std::make_unique<SSLConnectionOpenSSL>(
+ _clientContext.get(), socket, (const char*)nullptr, 0);
const auto undotted = removeFQDNRoot(socket->remoteAddr().hostOrIp());
int ret = ::SSL_set_tlsext_host_name(sslConn->ssl, undotted.c_str());
@@ -1497,7 +1497,7 @@ StatusWith<SSLPeerInfo> SSLManagerOpenSSL::parseAndValidatePeerCertificate(
X509* peerCert = SSL_get_peer_certificate(conn);
- if (NULL == peerCert) { // no certificate presented by peer
+ if (nullptr == peerCert) { // no certificate presented by peer
if (_weakValidation) {
// do not give warning if certificate warnings are suppressed
if (!_suppressNoCertificateWarning) {
@@ -1561,9 +1561,9 @@ StatusWith<SSLPeerInfo> SSLManagerOpenSSL::parseAndValidatePeerCertificate(
StringBuilder certificateNames;
STACK_OF(GENERAL_NAME)* sanNames = static_cast<STACK_OF(GENERAL_NAME)*>(
- X509_get_ext_d2i(peerCert, NID_subject_alt_name, NULL, NULL));
+ X509_get_ext_d2i(peerCert, NID_subject_alt_name, nullptr, nullptr));
- if (sanNames != NULL) {
+ if (sanNames != nullptr) {
int sanNamesList = sk_GENERAL_NAME_num(sanNames);
certificateNames << "SAN(s): ";
for (int i = 0; i < sanNamesList; i++) {