Skip to content

Commit 4c85eeb

Browse files
committed
Bugfix: protocol: Check for and handle (to the extent possible) snprintf errors
1 parent 9463f72 commit 4c85eeb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/datum_protocol.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,12 @@ int datum_protocol_pow(void *arg) {
13341334
// append the miner's username to the configured address as .workername
13351335
j = snprintf(username, 385, "%s%s%s", datum_config.mining_pool_address, (pow->username[0] == '.') ? "" : ".", pow->username);
13361336
}
1337+
if (j < 0) {
1338+
DLOG_ERROR("Unexpected error copying username to POW!");
1339+
// Still submit it without a username in case it's a block
1340+
username[0] = '\0';
1341+
j = 0;
1342+
}
13371343
if (j > 384) j = 384;
13381344
i += j + 1; // including final null byte
13391345

0 commit comments

Comments
 (0)