Address code analysis warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
@@ -40,7 +40,7 @@ eap::config::config(_In_ const config &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::config::config(_Inout_ config &&other) :
|
||||
eap::config::config(_Inout_ config &&other) noexcept :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
@@ -55,7 +55,7 @@ eap::config& eap::config::operator=(_In_ const config &other)
|
||||
}
|
||||
|
||||
|
||||
eap::config& eap::config::operator=(_Inout_ config &&other)
|
||||
eap::config& eap::config::operator=(_Inout_ config &&other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
assert(&m_module == &other.m_module);
|
||||
@@ -103,7 +103,7 @@ eap::config_method::config_method(_In_ const config_method &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::config_method::config_method(_Inout_ config_method &&other) :
|
||||
eap::config_method::config_method(_Inout_ config_method &&other) noexcept :
|
||||
m_level (std::move(other.m_level )),
|
||||
m_allow_save (std::move(other.m_allow_save )),
|
||||
m_last_status(std::move(other.m_last_status)),
|
||||
@@ -127,7 +127,7 @@ eap::config_method& eap::config_method::operator=(_In_ const config_method &othe
|
||||
}
|
||||
|
||||
|
||||
eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other)
|
||||
eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
assert(m_level == other.m_level); // Allow move within same configuration level only.
|
||||
@@ -231,7 +231,7 @@ eap::config_method_with_cred::config_method_with_cred(_In_ const config_method_w
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_with_cred::config_method_with_cred(_Inout_ config_method_with_cred &&other) :
|
||||
eap::config_method_with_cred::config_method_with_cred(_Inout_ config_method_with_cred &&other) noexcept :
|
||||
m_use_cred (std::move(other.m_use_cred)),
|
||||
m_cred (std::move(other.m_cred )),
|
||||
config_method(std::move(other ))
|
||||
@@ -251,7 +251,7 @@ eap::config_method_with_cred& eap::config_method_with_cred::operator=(_In_ const
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_with_cred& eap::config_method_with_cred::operator=(_Inout_ config_method_with_cred &&other)
|
||||
eap::config_method_with_cred& eap::config_method_with_cred::operator=(_Inout_ config_method_with_cred &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&)*this = std::move(other );
|
||||
@@ -362,7 +362,7 @@ eap::config_provider::config_provider(_In_ const config_provider &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::config_provider::config_provider(_Inout_ config_provider &&other) :
|
||||
eap::config_provider::config_provider(_Inout_ config_provider &&other) noexcept :
|
||||
m_namespace (std::move(other.m_namespace )),
|
||||
m_id (std::move(other.m_id )),
|
||||
m_read_only (std::move(other.m_read_only )),
|
||||
@@ -404,7 +404,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
|
||||
}
|
||||
|
||||
|
||||
eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other)
|
||||
eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = std::move(other );
|
||||
@@ -700,7 +700,7 @@ eap::config_connection::config_connection(_In_ const config_connection &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::config_connection::config_connection(_Inout_ config_connection &&other) :
|
||||
eap::config_connection::config_connection(_Inout_ config_connection &&other) noexcept :
|
||||
m_providers(std::move(other.m_providers)),
|
||||
config (std::move(other ))
|
||||
{
|
||||
@@ -718,7 +718,7 @@ eap::config_connection& eap::config_connection::operator=(_In_ const config_conn
|
||||
}
|
||||
|
||||
|
||||
eap::config_connection& eap::config_connection::operator=(_Inout_ config_connection &&other)
|
||||
eap::config_connection& eap::config_connection::operator=(_Inout_ config_connection &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = std::move(other );
|
||||
|
@@ -53,7 +53,7 @@ eap::credentials::credentials(_In_ const credentials &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::credentials(_Inout_ credentials &&other) :
|
||||
eap::credentials::credentials(_Inout_ credentials &&other) noexcept :
|
||||
m_identity(std::move(other.m_identity)),
|
||||
config(std::move(other))
|
||||
{
|
||||
@@ -71,7 +71,7 @@ eap::credentials& eap::credentials::operator=(_In_ const credentials &other)
|
||||
}
|
||||
|
||||
|
||||
eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other)
|
||||
eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = std::move(other);
|
||||
@@ -177,7 +177,7 @@ eap::credentials_identity::credentials_identity(_In_ const credentials_identity
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_identity::credentials_identity(_Inout_ credentials_identity &&other) : credentials(std::move(other))
|
||||
eap::credentials_identity::credentials_identity(_Inout_ credentials_identity &&other) noexcept : credentials(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ eap::credentials_identity& eap::credentials_identity::operator=(_In_ const crede
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_identity& eap::credentials_identity::operator=(_Inout_ credentials_identity &&other)
|
||||
eap::credentials_identity& eap::credentials_identity::operator=(_Inout_ credentials_identity &&other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
(credentials&)*this = std::move(other);
|
||||
@@ -297,7 +297,7 @@ LPCTSTR eap::credentials_identity::target_suffix() const
|
||||
|
||||
eap::credentials::source_t eap::credentials_identity::combine(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ const credentials *cred_cached,
|
||||
_In_ const config_method &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName)
|
||||
@@ -359,7 +359,7 @@ eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) :
|
||||
eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) noexcept :
|
||||
m_password (std::move(other.m_password)),
|
||||
m_enc_alg (std::move(other.m_enc_alg )),
|
||||
credentials(std::move(other ))
|
||||
@@ -379,7 +379,7 @@ eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_p
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other)
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = std::move(other );
|
||||
@@ -603,7 +603,7 @@ LPCTSTR eap::credentials_pass::target_suffix() const
|
||||
|
||||
eap::credentials::source_t eap::credentials_pass::combine(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ const credentials *cred_cached,
|
||||
_In_ const config_method &cfg,
|
||||
_In_opt_z_ LPCTSTR pszTargetName)
|
||||
@@ -737,7 +737,7 @@ eap::credentials_connection::credentials_connection(_In_ const credentials_conne
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) :
|
||||
eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) noexcept :
|
||||
m_cfg ( other.m_cfg ),
|
||||
m_namespace(std::move(other.m_namespace)),
|
||||
m_id (std::move(other.m_id )),
|
||||
@@ -760,7 +760,7 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other)
|
||||
eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = std::move(other );
|
||||
@@ -948,7 +948,7 @@ template<class _Elem, class _Traits, class _Ax>
|
||||
inline static basic_string<_Elem, _Traits, _Ax> kph_encrypt(_In_ HCRYPTPROV hProv, _In_z_ const char *src)
|
||||
{
|
||||
basic_string<_Elem, _Traits, _Ax> str;
|
||||
unsigned short key[8];
|
||||
unsigned short key[8] = { 0 };
|
||||
|
||||
// Generate the key.
|
||||
if (!CryptGenRandom(hProv, sizeof(key), (BYTE*)key))
|
||||
|
@@ -34,13 +34,13 @@ eap::method::method(_In_ module &mod) :
|
||||
}
|
||||
|
||||
|
||||
eap::method::method(_Inout_ method &&other) :
|
||||
eap::method::method(_Inout_ method &&other) noexcept :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::method& eap::method::operator=(_Inout_ method &&other)
|
||||
eap::method& eap::method::operator=(_Inout_ method &&other) noexcept
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
assert(std::addressof(m_module) == std::addressof(other.m_module)); // Move method within same module only!
|
||||
@@ -96,7 +96,7 @@ EapPeerMethodResponseAction eap::method::set_ui_context(
|
||||
}
|
||||
|
||||
|
||||
void eap::method::get_response_attributes(_Inout_ EapAttributes *pAttribs)
|
||||
void eap::method::get_response_attributes(_Out_ EapAttributes *pAttribs)
|
||||
{
|
||||
assert(pAttribs);
|
||||
|
||||
@@ -126,14 +126,14 @@ eap::method_tunnel::method_tunnel(_In_ module &mod, _In_ method *inner) :
|
||||
}
|
||||
|
||||
|
||||
eap::method_tunnel::method_tunnel(_Inout_ method_tunnel &&other) :
|
||||
eap::method_tunnel::method_tunnel(_Inout_ method_tunnel &&other) noexcept :
|
||||
m_inner(std::move(other.m_inner)),
|
||||
method (std::move(other ))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::method_tunnel& eap::method_tunnel::operator=(_Inout_ method_tunnel &&other)
|
||||
eap::method_tunnel& eap::method_tunnel::operator=(_Inout_ method_tunnel &&other) noexcept
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
(method&)*this = std::move(other );
|
||||
@@ -213,7 +213,7 @@ EapPeerMethodResponseAction eap::method_tunnel::set_ui_context(
|
||||
}
|
||||
|
||||
|
||||
void eap::method_tunnel::get_response_attributes(_Inout_ EapAttributes *pAttribs)
|
||||
void eap::method_tunnel::get_response_attributes(_Out_ EapAttributes *pAttribs)
|
||||
{
|
||||
assert(m_inner);
|
||||
m_inner->get_response_attributes(pAttribs);
|
||||
@@ -240,7 +240,7 @@ eap::method_eap::method_eap(_In_ module &mod, _In_ winstd::eap_type_t eap_method
|
||||
}
|
||||
|
||||
|
||||
eap::method_eap::method_eap(_Inout_ method_eap &&other) :
|
||||
eap::method_eap::method_eap(_Inout_ method_eap &&other) noexcept :
|
||||
m_eap_method (std::move(other.m_eap_method)),
|
||||
m_id (std::move(other.m_id )),
|
||||
m_send_nak (std::move(other.m_send_nak )),
|
||||
@@ -249,7 +249,7 @@ eap::method_eap::method_eap(_Inout_ method_eap &&other) :
|
||||
}
|
||||
|
||||
|
||||
eap::method_eap& eap::method_eap::operator=(_Inout_ method_eap &&other)
|
||||
eap::method_eap& eap::method_eap::operator=(_Inout_ method_eap &&other) noexcept
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
assert(m_eap_method == other.m_eap_method); // Move method within same EAP method type only!
|
||||
@@ -274,7 +274,7 @@ void eap::method_eap::begin_session(
|
||||
// Inner method can generate packets of up to 64kB (less the EAP packet header).
|
||||
// Initialize inner method with appropriately less packet size maximum.
|
||||
if (dwMaxSendPacketSize < sizeof(EapPacket))
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %u, available: %u).", sizeof(EapPacket) + 1, dwMaxSendPacketSize));
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %zu, available: %u).", sizeof(EapPacket) + 1, dwMaxSendPacketSize));
|
||||
assert(m_inner);
|
||||
m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min<DWORD>(dwMaxSendPacketSize, MAXWORD) - sizeof(EapPacket));
|
||||
}
|
||||
@@ -337,7 +337,7 @@ void eap::method_eap::get_response_packet(
|
||||
// Check packet size. We will suggest one EAP method alone, so we need one byte for data.
|
||||
size_t size_packet = sizeof(EapPacket) + 1;
|
||||
if (size_packet > size_max)
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", size_packet, size_max));
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", size_packet, size_max));
|
||||
packet.reserve(size_packet); // To avoid reallocation when inserting EAP packet header later.
|
||||
|
||||
// Data of Legacy Nak packet is a list of supported EAP types: our method alone.
|
||||
|
@@ -28,7 +28,7 @@ using namespace winstd;
|
||||
// eap::module
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::module::module(eap_type_t eap_method) :
|
||||
eap::module::module(_In_ eap_type_t eap_method) :
|
||||
m_eap_method(eap_method),
|
||||
m_instance(NULL)
|
||||
{
|
||||
@@ -141,16 +141,16 @@ EAP_ERROR* eap::module::make_error(_In_ const EAP_ERROR *err) const
|
||||
}
|
||||
|
||||
|
||||
BYTE* eap::module::alloc_memory(_In_ size_t size)
|
||||
BYTE* eap::module::alloc_memory(_In_ size_t size) const
|
||||
{
|
||||
BYTE *p = (BYTE*)HeapAlloc(m_heap, 0, size);
|
||||
if (!p)
|
||||
throw win_runtime_error(winstd::string_printf(__FUNCTION__ " Error allocating memory for BLOB (%uB).", size));
|
||||
throw win_runtime_error(winstd::string_printf(__FUNCTION__ " Error allocating memory for BLOB (%zuB).", size));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_memory(_In_ BYTE *ptr)
|
||||
void eap::module::free_memory(_In_ BYTE *ptr) const
|
||||
{
|
||||
#if !EAP_ENCRYPT_BLOBS
|
||||
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing.
|
||||
@@ -160,7 +160,7 @@ void eap::module::free_memory(_In_ BYTE *ptr)
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_error_memory(_In_ EAP_ERROR *err)
|
||||
void eap::module::free_error_memory(_In_ EAP_ERROR *err) const
|
||||
{
|
||||
// pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations.
|
||||
HeapFree(m_heap, 0, err);
|
||||
@@ -193,7 +193,7 @@ eap::config_method* eap::module::make_config_method()
|
||||
}
|
||||
|
||||
|
||||
std::vector<unsigned char> eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash) const
|
||||
std::vector<unsigned char> eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash) const
|
||||
{
|
||||
// Generate 256-bit AES session key.
|
||||
crypt_key key_aes;
|
||||
@@ -202,9 +202,11 @@ std::vector<unsigned char> eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytec
|
||||
|
||||
// Import the public RSA key.
|
||||
HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA);
|
||||
assert(res);
|
||||
if (!res)
|
||||
throw winstd::win_runtime_error(__FUNCTION__ " FindResource failed.");
|
||||
HGLOBAL res_handle = LoadResource(m_instance, res);
|
||||
assert(res_handle);
|
||||
if (!res_handle)
|
||||
throw winstd::win_runtime_error(__FUNCTION__ " LoadResource failed.");
|
||||
crypt_key key_rsa;
|
||||
unique_ptr<CERT_PUBLIC_KEY_INFO, LocalFree_delete<CERT_PUBLIC_KEY_INFO> > keyinfo_data;
|
||||
DWORD keyinfo_size = 0;
|
||||
@@ -321,13 +323,13 @@ void eap::peer::query_interactive_ui_input_fields(
|
||||
|
||||
|
||||
void eap::peer::query_ui_blob_from_interactive_ui_input_fields(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwUIContextDataSize,
|
||||
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
|
||||
_In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
|
||||
_Out_ DWORD *pdwDataFromInteractiveUISize,
|
||||
_Out_ BYTE **ppDataFromInteractiveUI) const
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwUIContextDataSize,
|
||||
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
|
||||
_In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
|
||||
_Out_ DWORD *pdwDataFromInteractiveUISize,
|
||||
_Outptr_result_buffer_(*pdwDataFromInteractiveUISize) BYTE **ppDataFromInteractiveUI) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwVersion);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
|
@@ -43,7 +43,7 @@ eap::ui_context::ui_context(_In_ const ui_context &other) :
|
||||
}
|
||||
|
||||
|
||||
eap::ui_context::ui_context(_Inout_ ui_context &&other) :
|
||||
eap::ui_context::ui_context(_Inout_ ui_context &&other) noexcept :
|
||||
m_cfg ( other.m_cfg ),
|
||||
m_cred ( other.m_cred ),
|
||||
packable(std::move(other ))
|
||||
@@ -63,7 +63,7 @@ eap::ui_context& eap::ui_context::operator=(_In_ const ui_context &other)
|
||||
}
|
||||
|
||||
|
||||
eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other)
|
||||
eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only!
|
||||
|
Reference in New Issue
Block a user