diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 5e8da32..b72fea7 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -438,7 +438,13 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo if (target >= TARGET_4_BYTES_LIMIT) { // "Low diff share" fix: adjust target to the same value as XMRig would use - target = std::numeric_limits::max() / (std::numeric_limits::max() / (target >> 32)); + const uint64_t upper_bits = target >> 32; + if (upper_bits > 0) { + const uint64_t divisor = std::numeric_limits::max() / upper_bits; + if (divisor > 0) { + target = std::numeric_limits::max() / divisor; + } + } } SubmittedShare share{}; diff --git a/src/wallet.cpp b/src/wallet.cpp index 7e4e881..368a274 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -202,13 +202,13 @@ bool Wallet::decode(const char* address) { char spend_hex[65] = {0}, view_hex[65] = {0}, data_hex[200] = {0}, prefix_hex[20] = {0}; for (int i = 0; i < 32; i++) { - sprintf(spend_hex + static_cast(i)*2, "%02x", m_spendPublicKey.h[i]); - sprintf(view_hex + static_cast(i)*2, "%02x", m_viewPublicKey.h[i]); + snprintf(spend_hex + static_cast(i)*2, sizeof(spend_hex) - static_cast(i)*2, "%02x", m_spendPublicKey.h[i]); + snprintf(view_hex + static_cast(i)*2, sizeof(view_hex) - static_cast(i)*2, "%02x", m_viewPublicKey.h[i]); } for (int i = 0; i < std::min(data_index, 80); i++) { - sprintf(data_hex + static_cast(i)*2, "%02x", data[i]); + snprintf(data_hex + static_cast(i)*2, sizeof(data_hex) - static_cast(i)*2, "%02x", data[i]); } - sprintf(prefix_hex, "0x%llx", static_cast(m_prefix)); + snprintf(prefix_hex, sizeof(prefix_hex), "0x%llx", static_cast(m_prefix)); LOGINFO(6, "decode varint_len=" << varint_len << " data_index=" << data_index << " prefix=" << static_cast(prefix_hex)); LOGINFO(6, "decode raw_data: " << static_cast(data_hex)); LOGINFO(6, "decode spend: " << static_cast(spend_hex));