diff options
| author | tobtoht <tob@featherwallet.org> | 2026-03-01 11:28:46 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2026-03-01 11:28:46 +0000 |
| commit | 23b420a992417abb6131b3d152d7e32adf224351 (patch) | |
| tree | 67c06379d557f7525da4d91c299450f7568611f9 /src/cryptonote_basic/cryptonote_format_utils.cpp | |
| parent | 761654b880f3933fb3c390265a441a5cc83797aa (diff) | |
| parent | 1e6a55109f4434b166a35a26123d7a4370a507b7 (diff) | |
| download | monzero-core-23b420a992417abb6131b3d152d7e32adf224351.tar.gz monzero-core-23b420a992417abb6131b3d152d7e32adf224351.tar.xz monzero-core-23b420a992417abb6131b3d152d7e32adf224351.zip | |
Merge pull request #10337
1e6a551 cryptonote_basic: fix add_extra_nonce_to_tx_extra() length (jeffro256)
Diffstat (limited to 'src/cryptonote_basic/cryptonote_format_utils.cpp')
| -rw-r--r-- | src/cryptonote_basic/cryptonote_format_utils.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index ea1508505..a6d7762ff 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -741,15 +741,19 @@ namespace cryptonote { CHECK_AND_ASSERT_MES(extra_nonce.size() <= TX_EXTRA_NONCE_MAX_COUNT, false, "extra nonce could be 255 bytes max"); size_t start_pos = tx_extra.size(); - tx_extra.resize(tx_extra.size() + 2 + extra_nonce.size()); + const std::size_t len_varint_bytes = tools::get_varint_byte_size(extra_nonce.size()); + tx_extra.resize(tx_extra.size() + 1 + len_varint_bytes + extra_nonce.size()); //write tag tx_extra[start_pos] = TX_EXTRA_NONCE; //write len ++start_pos; - tx_extra[start_pos] = static_cast<uint8_t>(extra_nonce.size()); + unsigned char * vp = tx_extra.data() + start_pos; + tools::write_varint(vp, extra_nonce.size()); + assert(vp == tx_extra.data() + tx_extra.size() - extra_nonce.size()); //write data - ++start_pos; - memcpy(&tx_extra[start_pos], extra_nonce.data(), extra_nonce.size()); + start_pos += len_varint_bytes; + if (!extra_nonce.empty()) + memcpy(&tx_extra[start_pos], extra_nonce.data(), extra_nonce.size()); return true; } //--------------------------------------------------------------- |
