From 41e73f3d947c6c3ce4f612c78a69db73a0447c48 Mon Sep 17 00:00:00 2001 From: Intel Date: Thu, 8 May 2014 10:00:11 -0400 Subject: [PATCH] Fix crash --- src/server/poolserver/Stratum/Client.cpp | 10 +++++++--- src/server/shared/Util.cpp | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server/poolserver/Stratum/Client.cpp b/src/server/poolserver/Stratum/Client.cpp index fde4a79..a5c023b 100644 --- a/src/server/poolserver/Stratum/Client.cpp +++ b/src/server/poolserver/Stratum/Client.cpp @@ -39,6 +39,9 @@ namespace Stratum _jobs[jobid] = job; + std::stringstream jobss; + jobss << std::hex << jobid; + // Build merkle branch array JSON merkle_branch(JSON_ARRAY); uint64 branches = job.block->merkleBranches; @@ -57,7 +60,7 @@ namespace Stratum prevhashfixed << prevhash[0] << prevhash[1] << prevhash[2] << prevhash[3] << prevhash[4] << prevhash[5] << prevhash[6] << prevhash[7]; JSON params; - params.Add(Util::BinToASCII(ByteBuffer(jobid).Binary())); + params.Add(jobss.str()); params.Add(Util::BinToASCII(prevhashfixed.Binary())); params.Add(Util::BinToASCII(job.coinbase1)); params.Add(Util::BinToASCII(job.coinbase2)); @@ -94,8 +97,9 @@ namespace Stratum } uint32 jobid; - ByteBuffer jobbuf(Util::ASCIIToBin(params[1].GetString())); - jobbuf >> jobid; + std::stringstream jobss; + jobss << std::hex << params[1].GetString(); + jobss >> jobid; // Check if such job exists if (!_jobs.count(jobid)) { diff --git a/src/server/shared/Util.cpp b/src/server/shared/Util.cpp index 24d8f73..afe0e76 100644 --- a/src/server/shared/Util.cpp +++ b/src/server/shared/Util.cpp @@ -86,7 +86,7 @@ uint8 Util::ASCIIToHex(char ch) BinaryData Util::ASCIIToBin(std::string str) { BinaryData data; - data.resize(str.size()/2, 0); + data.resize((str.size()+1)/2, 0); for (uint64 i = 0; i < str.size(); ++i) { if (i%2) data[i/2] += ASCIIToHex(str[i]);