#3185 Fixed macOS DMI reader.

This commit is contained in:
XMRig 2023-01-19 22:09:59 +07:00
parent 44642643f8
commit 770b71c69a
No known key found for this signature in database
GPG key ID: 446A53638BE94409

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2002-2006 Hugo Weber <address@hidden> * Copyright (c) 2002-2006 Hugo Weber <address@hidden>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "hw/dmi/DmiReader.h" #include "hw/dmi/DmiReader.h"
#include "hw/dmi/DmiTools.h" #include "hw/dmi/DmiTools.h"
@ -91,12 +90,12 @@ bool xmrig::DmiReader::read()
} }
CFDataRef data = reinterpret_cast<CFDataRef>(IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions)); CFDataRef data = reinterpret_cast<CFDataRef>(IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions));
if (!data) { if (!data || CFDataGetLength(data) < 0x1f) {
return false; return false;
} }
uint8_t buf[0x20]{}; uint8_t buf[0x20]{};
CFDataGetBytes(data, CFRangeMake(0, sizeof(buf)), buf); CFDataGetBytes(data, CFRangeMake(0, sizeof(buf) - 1), buf);
CFRelease(data); CFRelease(data);
auto smb = smbios_decode(buf, m_size, m_version, service); auto smb = smbios_decode(buf, m_size, m_version, service);