Uninitialized enum higher bytes when reading as unsigned char fixed

This commit is contained in:
Simon Rozman 2017-02-09 11:38:57 +01:00
parent bda31a487f
commit e7e57abf52
3 changed files with 5 additions and 0 deletions

View File

@ -510,6 +510,7 @@ inline size_t pksizeof(_In_ const eap::config_method::status_t &val)
/// ///
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config_method::status_t &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config_method::status_t &val)
{ {
val = (eap::config_method::status_t)0; // Reset higher bytes to zero before reading to lower byte.
cursor >> (unsigned char&)val; cursor >> (unsigned char&)val;
} }

View File

@ -571,6 +571,7 @@ inline size_t pksizeof(_In_ const eap::credentials_pass::enc_alg_t &val)
/// ///
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::credentials_pass::enc_alg_t &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::credentials_pass::enc_alg_t &val)
{ {
val = (eap::credentials_pass::enc_alg_t)0; // Reset higher bytes to zero before reading to lower byte.
cursor >> (unsigned char&)val; cursor >> (unsigned char&)val;
} }

View File

@ -1153,9 +1153,11 @@ inline size_t pksizeof(_In_ const winstd::cert_context &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_context &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_context &val)
{ {
DWORD dwCertEncodingType; DWORD dwCertEncodingType;
assert(sizeof(dwCertEncodingType) == sizeof(unsigned int));
cursor >> (unsigned int&)dwCertEncodingType; cursor >> (unsigned int&)dwCertEncodingType;
DWORD dwCertEncodedSize; DWORD dwCertEncodedSize;
assert(sizeof(dwCertEncodingType) == sizeof(unsigned int));
cursor >> (unsigned int&)dwCertEncodedSize; cursor >> (unsigned int&)dwCertEncodedSize;
if (dwCertEncodedSize) { if (dwCertEncodedSize) {
@ -1182,6 +1184,7 @@ inline size_t pksizeof(_In_ const winstd::eap_type_t &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::eap_type_t &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::eap_type_t &val)
{ {
val = (winstd::eap_type_t)0; // Reset higher bytes to zero before reading to lower byte.
cursor >> (unsigned char&)val; cursor >> (unsigned char&)val;
} }