Add explicit constructors/operators to sanitizing_blob_(z)f

Otherwise the compiler might generate default ones - and delete them
too.
This commit is contained in:
Simon Rozman 2018-09-04 15:49:48 +02:00
parent 9f13059d66
commit 192e1b278c

View File

@ -672,6 +672,16 @@ namespace eap
memcpy(data, other.data, N);
}
///
/// Moves the BLOB
///
/// \param[inout] other BLOB to move from
///
inline sanitizing_blob_f(_Inout_ sanitizing_blob_f<N> &&other)
{
memcpy(data, other.data, N);
}
///
/// Moves the BLOB
///
@ -708,7 +718,21 @@ namespace eap
///
/// Moves the BLOB
///
/// \param[inout] other Zero-initialized BLOB to copy from
/// \param[inout] other BLOB to move from
///
/// \returns Reference to this object
///
inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_f<N> &&other)
{
if (this != std::addressof(other))
memcpy(data, other.data, N);
return *this;
}
///
/// Moves the BLOB
///
/// \param[inout] other Zero-initialized BLOB to move from
///
/// \returns Reference to this object
///
@ -791,9 +815,9 @@ namespace eap
///
/// Copies a BLOB
///
/// \param[in] other BLOB to copy from
/// \param[in] other Zero-initialized BLOB to copy from
///
inline sanitizing_blob_zf(_In_ const sanitizing_blob_f<N> &other) :
inline sanitizing_blob_zf(_In_ const sanitizing_blob_zf<N> &other) :
sanitizing_blob_f<N>(other)
{
}
@ -806,6 +830,85 @@ namespace eap
inline sanitizing_blob_zf(_Inout_ sanitizing_blob_zf<N> &&other) :
sanitizing_blob_f<N>(std::move(other))
{
memset(other.data, 0, N);
}
///
/// Copies a BLOB
///
/// \param[in] other BLOB to copy from
///
inline sanitizing_blob_zf(_In_ const sanitizing_blob_f<N> &other) :
sanitizing_blob_f<N>(other)
{
}
///
/// Moves the BLOB
///
/// \param[inout] other BLOB to move from
///
inline sanitizing_blob_zf(_Inout_ sanitizing_blob_f<N> &&other) :
sanitizing_blob_f<N>(std::move(other))
{
}
///
/// Copies a BLOB
///
/// \param[in] other Zero-initialized BLOB to copy from
///
/// \returns Reference to this object
///
inline sanitizing_blob_zf& operator=(_In_ const sanitizing_blob_zf<N> &other)
{
if (this != std::addressof(other))
memcpy(data, other.data, N);
return *this;
}
///
/// Moves the BLOB
///
/// \param[inout] other Zero-initialized BLOB to move from
///
/// \returns Reference to this object
///
inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_zf<N> &&other)
{
if (this != std::addressof(other)) {
memcpy(data, other.data, N);
memset(other.data, 0, N);
}
return *this;
}
///
/// Copies a BLOB
///
/// \param[in] other BLOB to copy from
///
/// \returns Reference to this object
///
inline sanitizing_blob_zf& operator=(_In_ const sanitizing_blob_f<N> &other)
{
if (this != std::addressof(other))
memcpy(data, other.data, N);
return *this;
}
///
/// Moves the BLOB
///
/// \param[inout] other BLOB to move from
///
/// \returns Reference to this object
///
inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_f<N> &&other)
{
if (this != std::addressof(other))
memcpy(data, other.data, N);
return *this;
}
};
#pragma pack(pop)