From 770b71c69a07888407cc870bea6ecc3e81acc886 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 19 Jan 2023 22:09:59 +0700 Subject: [PATCH] #3185 Fixed macOS DMI reader. --- src/hw/dmi/DmiReader_mac.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hw/dmi/DmiReader_mac.cpp b/src/hw/dmi/DmiReader_mac.cpp index a23bfe47f..bf9eb376a 100644 --- a/src/hw/dmi/DmiReader_mac.cpp +++ b/src/hw/dmi/DmiReader_mac.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2002-2006 Hugo Weber - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "hw/dmi/DmiReader.h" #include "hw/dmi/DmiTools.h" @@ -91,12 +90,12 @@ bool xmrig::DmiReader::read() } CFDataRef data = reinterpret_cast(IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions)); - if (!data) { + if (!data || CFDataGetLength(data) < 0x1f) { return false; } uint8_t buf[0x20]{}; - CFDataGetBytes(data, CFRangeMake(0, sizeof(buf)), buf); + CFDataGetBytes(data, CFRangeMake(0, sizeof(buf) - 1), buf); CFRelease(data); auto smb = smbios_decode(buf, m_size, m_version, service);