Skip to content

Commit

Permalink
fix: stricter validation of output chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Feb 19, 2024
1 parent 5ec8ac1 commit 9639137
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/signTxOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ static void handleDatumInline(read_view_t* view)
VALIDATE(chunkSize > 0, ERR_INVALID_DATA);
VALIDATE(chunkSize <= MAX_CHUNK_SIZE, ERR_INVALID_DATA);
VALIDATE(chunkSize <= subctx->stateData.datumRemainingBytes, ERR_INVALID_DATA);
if (subctx->stateData.datumRemainingBytes >= MAX_CHUNK_SIZE) {
// forces to use chunks of maximum allowed size
VALIDATE(chunkSize == MAX_CHUNK_SIZE, ERR_INVALID_DATA);
}

view_parseBuffer(subctx->stateData.datumChunk, view, chunkSize);
VALIDATE(view_remainingSize(view) == 0, ERR_INVALID_DATA);
Expand Down Expand Up @@ -936,7 +940,10 @@ static void handleRefScriptChunkAPDU(const uint8_t* wireDataBuffer, size_t wireD
TRACE("chunkSize = %u", chunkSize);
VALIDATE(chunkSize > 0, ERR_INVALID_DATA);
VALIDATE(chunkSize <= MAX_CHUNK_SIZE, ERR_INVALID_DATA);

if (subctx->stateData.datumRemainingBytes >= MAX_CHUNK_SIZE) {
// forces to use chunks of maximum allowed size
VALIDATE(chunkSize == MAX_CHUNK_SIZE, ERR_INVALID_DATA);
}
VALIDATE(chunkSize <= subctx->stateData.refScriptRemainingBytes, ERR_INVALID_DATA);
subctx->stateData.refScriptRemainingBytes -= chunkSize;

Expand Down

0 comments on commit 9639137

Please sign in to comment.