From 8bd3b393efb048d97e95a43a6b0d6dd8adb0280b Mon Sep 17 00:00:00 2001 From: SChernykh <sergey.v.chernykh@gmail.com> Date: Mon, 19 Sep 2022 10:42:08 +0200 Subject: [PATCH] Update m_size only if blob was set successfully --- src/base/net/stratum/Job.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 7aa910bfc..56f5de804 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -64,19 +64,19 @@ bool xmrig::Job::setBlob(const char *blob) return false; } - m_size = strlen(blob); - if (m_size % 2 != 0) { + size_t size = strlen(blob); + if (size % 2 != 0) { return false; } - m_size /= 2; + size /= 2; const size_t minSize = nonceOffset() + nonceSize(); - if (m_size < minSize || m_size >= sizeof(m_blob)) { + if (size < minSize || size >= sizeof(m_blob)) { return false; } - if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, m_size * 2)) { + if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, size * 2)) { return false; } @@ -86,9 +86,10 @@ bool xmrig::Job::setBlob(const char *blob) # ifdef XMRIG_PROXY_PROJECT memset(m_rawBlob, 0, sizeof(m_rawBlob)); - memcpy(m_rawBlob, blob, m_size * 2); + memcpy(m_rawBlob, blob, size * 2); # endif + m_size = size; return true; }