From 611378eb968eeda5700fe257a27d87856aa112f0 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Fri, 6 Oct 2017 21:46:22 +0200 Subject: avoid possible illegal memory access Is is possible that the number of results are greater than the result output array, in this case invalid memory can be access within the device and on the host side. --- xmrstak/backend/amd/amd_gpu/gpu.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xmrstak/backend/amd/amd_gpu/gpu.cpp') diff --git a/xmrstak/backend/amd/amd_gpu/gpu.cpp b/xmrstak/backend/amd/amd_gpu/gpu.cpp index d43961e..ca81718 100644 --- a/xmrstak/backend/amd/amd_gpu/gpu.cpp +++ b/xmrstak/backend/amd/amd_gpu/gpu.cpp @@ -912,6 +912,10 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput) } clFinish(ctx->CommandQueues); + auto & numHashValues = HashOutput[0xFF]; + // avoid out of memory read, we have only storage for 0xFF results + if(numHashValues > 0xFF) + numHashValues = 0xFF; ctx->Nonce += g_intensity; return ERR_SUCCESS; -- cgit v1.1