1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-16 19:22:46 -05:00

Fixed unaligned memory accesses

This commit is contained in:
SChernykh
2022-01-26 15:26:23 +01:00
parent 41a3f97060
commit 644f4cc017
9 changed files with 74 additions and 14 deletions

View File

@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/tools/Alignment.h"
#include "crypto/common/Nonce.h"
@@ -53,10 +54,10 @@ bool xmrig::Nonce::next(uint8_t index, uint32_t *nonce, uint32_t reserveCount, u
continue;
}
*nonce = (nonce[0] & ~mask) | counter;
writeUnaligned(nonce, static_cast<uint32_t>((readUnaligned(nonce) & ~mask) | counter));
if (mask > 0xFFFFFFFFULL) {
nonce[1] = (nonce[1] & (~mask >> 32)) | (counter >> 32);
writeUnaligned(nonce + 1, static_cast<uint32_t>((readUnaligned(nonce + 1) & (~mask >> 32)) | (counter >> 32)));
}
return true;