mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 03:59:41 +00:00
Merge pull request #3051 from SChernykh/dev
Fixed unaligned memory read in DMI
This commit is contained in:
commit
059d5d8421
3 changed files with 6 additions and 6 deletions
|
@ -30,7 +30,7 @@ namespace xmrig {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T readUnaligned(const T* ptr)
|
inline T readUnaligned(const T* ptr)
|
||||||
{
|
{
|
||||||
static_assert(std::is_integral<T>::value, "Integer type required");
|
static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
|
||||||
|
|
||||||
T result;
|
T result;
|
||||||
memcpy(&result, ptr, sizeof(T));
|
memcpy(&result, ptr, sizeof(T));
|
||||||
|
@ -41,7 +41,7 @@ inline T readUnaligned(const T* ptr)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void writeUnaligned(T* ptr, T data)
|
inline void writeUnaligned(T* ptr, T data)
|
||||||
{
|
{
|
||||||
static_assert(std::is_integral<T>::value, "Integer type required");
|
static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
|
||||||
|
|
||||||
memcpy(ptr, &data, sizeof(T));
|
memcpy(ptr, &data, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
void randomx_set_huge_pages_jit(bool)
|
void randomx_set_huge_pages_jit(bool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void randomx_set_optimized_dataset_init(int)
|
void randomx_set_optimized_dataset_init(int)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include "base/tools/Alignment.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -45,10 +46,10 @@ struct u64 {
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T dmi_get(const uint8_t *data) { return *reinterpret_cast<const T *>(data); }
|
inline T dmi_get(const uint8_t *data) { return readUnaligned(reinterpret_cast<const T *>(data)); }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T dmi_get(const dmi_header *h, size_t offset) { return *reinterpret_cast<const T *>(h->data + offset); }
|
inline T dmi_get(const dmi_header *h, size_t offset) { return readUnaligned(reinterpret_cast<const T *>(h->data + offset)); }
|
||||||
|
|
||||||
|
|
||||||
const char *dmi_string(dmi_header *dm, size_t offset);
|
const char *dmi_string(dmi_header *dm, size_t offset);
|
||||||
|
|
Loading…
Reference in a new issue