diff options
author | Jose <jose@zeroc.com> | 2019-06-22 00:29:53 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-06-22 00:29:53 +0200 |
commit | c5959fd09de61604bedd75354401df6a57395d65 (patch) | |
tree | 3b0227f631c8b20fb1a1a274b92f63f52f34af2c /cpp/src/IceSSL | |
parent | Small fix (diff) | |
parent | Enable -Wconversion with clang - Close #363 (diff) | |
download | ice-c5959fd09de61604bedd75354401df6a57395d65.tar.bz2 ice-c5959fd09de61604bedd75354401df6a57395d65.tar.xz ice-c5959fd09de61604bedd75354401df6a57395d65.zip |
Merge remote-tracking branch 'origin/3.7' into swift
Diffstat (limited to 'cpp/src/IceSSL')
-rw-r--r-- | cpp/src/IceSSL/SecureTransportCertificateI.cpp | 13 | ||||
-rw-r--r-- | cpp/src/IceSSL/SecureTransportTransceiverI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceSSL/SecureTransportUtil.cpp | 22 | ||||
-rwxr-xr-x | cpp/src/IceSSL/Util.cpp | 8 |
4 files changed, 29 insertions, 24 deletions
diff --git a/cpp/src/IceSSL/SecureTransportCertificateI.cpp b/cpp/src/IceSSL/SecureTransportCertificateI.cpp index ad7f1e50aa7..611a940a3e0 100644 --- a/cpp/src/IceSSL/SecureTransportCertificateI.cpp +++ b/cpp/src/IceSSL/SecureTransportCertificateI.cpp @@ -459,8 +459,8 @@ SecureTransportCertificateI::getAuthorityKeyIdentifier() const { CFDataRef data = static_cast<CFDataRef>( CFDictionaryGetValue(static_cast<CFDictionaryRef>(value), kSecPropertyKeyValue)); - keyid.resize(CFDataGetLength(data)); - memcpy(&keyid[0], CFDataGetBytePtr(data), CFDataGetLength(data)); + keyid.resize(static_cast<size_t>(CFDataGetLength(data))); + memcpy(&keyid[0], CFDataGetBytePtr(data), static_cast<size_t>(CFDataGetLength(data))); } } } @@ -498,8 +498,8 @@ SecureTransportCertificateI::getSubjectKeyIdentifier() const { CFDataRef data = static_cast<CFDataRef>( CFDictionaryGetValue(static_cast<CFDictionaryRef>(value), kSecPropertyKeyValue)); - keyid.resize(CFDataGetLength(data)); - memcpy(&keyid[0], CFDataGetBytePtr(data), CFDataGetLength(data)); + keyid.resize(static_cast<size_t>(CFDataGetLength(data))); + memcpy(&keyid[0], CFDataGetBytePtr(data), static_cast<size_t>(CFDataGetLength(data))); } } } @@ -589,7 +589,8 @@ SecureTransportCertificateI::encode() const { throw CertificateEncodingException(__FILE__, __LINE__, sslErrorToString(err)); } - return string(reinterpret_cast<const char*>(CFDataGetBytePtr(exported.get())), CFDataGetLength(exported.get())); + return string(reinterpret_cast<const char*>(CFDataGetBytePtr(exported.get())), + static_cast<size_t>(CFDataGetLength(exported.get()))); #endif } @@ -839,7 +840,7 @@ IceSSL::SecureTransport::Certificate::decode(const std::string& encoding) UniqueRef<CFDataRef> data( CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(encoding.c_str()), - encoding.size(), kCFAllocatorNull)); + static_cast<CFIndex>(encoding.size()), kCFAllocatorNull)); SecExternalFormat format = kSecFormatUnknown; SecExternalItemType type = kSecItemTypeCertificate; diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index 00d0ad0fce5..63f9b54af75 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -213,8 +213,10 @@ IceSSL::SecureTransport::TransceiverI::initialize(IceInternal::Buffer& readBuffe // if(_delegate->getNativeInfo()->fd() != INVALID_SOCKET) { - _maxSendPacketSize = std::max(512, IceInternal::getSendBufferSize(_delegate->getNativeInfo()->fd())); - _maxRecvPacketSize = std::max(512, IceInternal::getRecvBufferSize(_delegate->getNativeInfo()->fd())); + _maxSendPacketSize = + static_cast<size_t>(std::max(512, IceInternal::getSendBufferSize(_delegate->getNativeInfo()->fd()))); + _maxRecvPacketSize = + static_cast<size_t>(std::max(512, IceInternal::getRecvBufferSize(_delegate->getNativeInfo()->fd()))); } else { @@ -584,7 +586,7 @@ IceSSL::SecureTransport::TransceiverI::writeRaw(const char* data, size_t* length IceInternal::SocketOperation op = _delegate->write(buf); if(op == IceInternal::SocketOperationWrite) { - *length = buf.i - buf.b.begin(); + *length = static_cast<size_t>(buf.i - buf.b.begin()); _tflags |= SSLWantWrite; return errSSLWouldBlock; } @@ -617,7 +619,7 @@ IceSSL::SecureTransport::TransceiverI::readRaw(char* data, size_t* length) const IceInternal::SocketOperation op = _delegate->read(buf); if(op == IceInternal::SocketOperationRead) { - *length = buf.i - buf.b.begin(); + *length = static_cast<size_t>(buf.i - buf.b.begin()); _tflags |= SSLWantRead; return errSSLWouldBlock; } diff --git a/cpp/src/IceSSL/SecureTransportUtil.cpp b/cpp/src/IceSSL/SecureTransportUtil.cpp index 5d20a56ee05..fbf7ebd53d1 100644 --- a/cpp/src/IceSSL/SecureTransportUtil.cpp +++ b/cpp/src/IceSSL/SecureTransportUtil.cpp @@ -36,12 +36,13 @@ readCertFile(const string& file) } is.seekg(0, is.end); - size_t size = is.tellg(); + size_t size = static_cast<size_t>(is.tellg()); is.seekg(0, is.beg); - UniqueRef<CFMutableDataRef> data(CFDataCreateMutable(kCFAllocatorDefault, size)); - CFDataSetLength(data.get(), size); - is.read(reinterpret_cast<char*>(CFDataGetMutableBytePtr(data.get())), size); + UniqueRef<CFMutableDataRef> data(CFDataCreateMutable(kCFAllocatorDefault, static_cast<CFIndex>(size))); + CFDataSetLength(data.get(), static_cast<CFIndex>(size)); + is.read(reinterpret_cast<char*>(CFDataGetMutableBytePtr(data.get())), + static_cast<streamsize>(size)); if(!is.good()) { throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file); @@ -243,7 +244,7 @@ openKeychain(const std::string& path, const std::string& keychainPassword) if(err == noErr) { const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str(); - if((err = SecKeychainUnlock(keychain.get(), static_cast<int>(keychainPassword.size()), pass, pass != 0))) + if((err = SecKeychainUnlock(keychain.get(), static_cast<UInt32>(keychainPassword.size()), pass, pass != 0))) { throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: unable to unlock keychain:\n" + sslErrorToString(err)); @@ -253,7 +254,8 @@ openKeychain(const std::string& path, const std::string& keychainPassword) { const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str(); keychain.reset(0); - if((err = SecKeychainCreate(keychainPath.c_str(), static_cast<int>(keychainPassword.size()), pass, pass == 0, 0, &keychain.get()))) + if((err = SecKeychainCreate(keychainPath.c_str(), + static_cast<UInt32>(keychainPassword.size()), pass, pass == 0, 0, &keychain.get()))) { throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: unable to create keychain:\n" + sslErrorToString(err)); @@ -405,7 +407,7 @@ loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keycha SecKeychainAttribute attr; attr.tag = kSecKeyLabel; attr.data = const_cast<UInt8*>(CFDataGetBytePtr(hash.get())); - attr.length = static_cast<int>(CFDataGetLength(hash.get())); + attr.length = static_cast<UInt32>(CFDataGetLength(hash.get())); attributes.push_back(attr); } @@ -421,13 +423,13 @@ loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keycha SecKeychainAttribute attr; attr.tag = kSecKeyPrintName; attr.data = const_cast<char*>(label.c_str()); - attr.length = static_cast<int>(label.size()); + attr.length = static_cast<UInt32>(label.size()); attributes.push_back(attr); } SecKeychainAttributeList attrs; attrs.attr = &attributes[0]; - attrs.count = static_cast<int>(attributes.size()); + attrs.count = static_cast<UInt32>(attributes.size()); SecKeychainItemModifyAttributesAndData(reinterpret_cast<SecKeychainItemRef>(key.get()), &attrs, 0, 0); UniqueRef<SecIdentityRef> identity; @@ -760,7 +762,7 @@ IceSSL::SecureTransport::findCertificateChain(const std::string& keychainPath, { throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: invalid value `" + value + "'"); } - UniqueRef<CFDataRef> v(CFDataCreate(kCFAllocatorDefault, &buffer[0], buffer.size())); + UniqueRef<CFDataRef> v(CFDataCreate(kCFAllocatorDefault, &buffer[0], static_cast<CFIndex>(buffer.size()))); CFDictionarySetValue(query.get(), field == "SUBJECTKEYID" ? kSecAttrSubjectKeyID : kSecAttrSerialNumber, v.get()); valid = true; diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp index 29a265814fa..294640565a5 100755 --- a/cpp/src/IceSSL/Util.cpp +++ b/cpp/src/IceSSL/Util.cpp @@ -36,8 +36,8 @@ IceSSL::fromCFString(CFStringRef v) { CFIndex size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(v), kCFStringEncodingUTF8); vector<char> buffer; - buffer.resize(size + 1); - CFStringGetCString(v, &buffer[0], buffer.size(), kCFStringEncodingUTF8); + buffer.resize(static_cast<size_t>(size + 1)); + CFStringGetCString(v, &buffer[0], static_cast<CFIndex>(buffer.size()), kCFStringEncodingUTF8); s.assign(&buffer[0]); } return s; @@ -118,12 +118,12 @@ IceSSL::readFile(const string& file, vector<char>& buffer) } is.seekg(0, is.end); - buffer.resize(static_cast<int>(is.tellg())); + buffer.resize(static_cast<size_t>(is.tellg())); is.seekg(0, is.beg); if(!buffer.empty()) { - is.read(&buffer[0], buffer.size()); + is.read(&buffer[0], static_cast<streamsize>(buffer.size())); if(!is.good()) { throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file); |