Skip to content

Commit

Permalink
fix: correct message sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Apr 11, 2024
1 parent a37524a commit 414aea6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sys-utils/libcmt/src/rollup.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ int cmt_rollup_emit_voucher(cmt_rollup_t *me, uint32_t address_length, const voi
}
// clang-format on

size_t m = cmt_buf_length(wr);
size_t used_space = wr->begin - tx->begin;
struct cmt_io_yield req[1] = {{
.dev = HTIF_DEVICE_YIELD,
.cmd = HTIF_YIELD_CMD_AUTOMATIC,
.reason = HTIF_YIELD_AUTOMATIC_REASON_TX_OUTPUT,
.data = m,
.data = used_space,
}};
int rc = DBG(cmt_io_yield(me->io, req));
if (rc) {
Expand All @@ -107,7 +107,7 @@ int cmt_rollup_emit_voucher(cmt_rollup_t *me, uint32_t address_length, const voi

uint64_t count = cmt_merkle_get_leaf_count(me->merkle);

rc = cmt_merkle_push_back_data(me->merkle, m, tx->begin);
rc = cmt_merkle_push_back_data(me->merkle, used_space, tx->begin);
if (rc) {
return rc;
}
Expand Down Expand Up @@ -140,12 +140,12 @@ int cmt_rollup_emit_notice(cmt_rollup_t *me, uint32_t length, const void *data,
}
// clang-format on

size_t m = cmt_buf_length(wr);
size_t used_space = wr->begin - tx->begin;
struct cmt_io_yield req[1] = {{
.dev = HTIF_DEVICE_YIELD,
.cmd = HTIF_YIELD_CMD_AUTOMATIC,
.reason = HTIF_YIELD_AUTOMATIC_REASON_TX_OUTPUT,
.data = m,
.data = used_space,
}};
int rc = DBG(cmt_io_yield(me->io, req));
if (rc) {
Expand All @@ -154,7 +154,7 @@ int cmt_rollup_emit_notice(cmt_rollup_t *me, uint32_t length, const void *data,

uint64_t count = cmt_merkle_get_leaf_count(me->merkle);

rc = cmt_merkle_push_back_data(me->merkle, m, tx->begin);
rc = cmt_merkle_push_back_data(me->merkle, used_space, tx->begin);
if (rc) {
return rc;
}
Expand Down Expand Up @@ -317,7 +317,7 @@ int cmt_rollup_finish(cmt_rollup_t *me, cmt_rollup_finish_t *finish) {
}

cmt_merkle_get_root_hash(me->merkle, cmt_io_get_tx(me->io).begin);
finish->next_request_payload_length = CMT_WORD_LENGTH;
me->fromhost_data = CMT_WORD_LENGTH;
int reason = accepted(me->io, &me->fromhost_data);
if (reason < 0) {
return reason;
Expand Down Expand Up @@ -347,8 +347,7 @@ int cmt_gio_request(cmt_rollup_t *me, cmt_gio_t *req) {
return -ENOBUFS;
}
if (req->id) {
memcpy(wr->begin, req->id,
req->id_length); // NOLINT(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
memcpy(wr->begin, req->id, req->id_length);
}

struct cmt_io_yield rr[1] = {{
Expand Down

0 comments on commit 414aea6

Please sign in to comment.