mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
wally: Making extra sure that pulling a TX results in the correct read offset.
This commit is contained in:
parent
4f0c386d32
commit
ce58cba9fe
1 changed files with 4 additions and 0 deletions
|
@ -556,12 +556,15 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
|
|||
size_t i;
|
||||
u64 count;
|
||||
u8 flag = 0;
|
||||
const u8 *oldcursor = *cursor;
|
||||
size_t wsize;
|
||||
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
|
||||
if (wally_tx_from_bytes(*cursor, *max, 0, &tx->wtx) != WALLY_OK) {
|
||||
*cursor = 0;
|
||||
return tal_free(tx);
|
||||
}
|
||||
tal_add_destructor(tx, bitcoin_tx_destroy);
|
||||
wally_tx_get_length(tx->wtx, WALLY_TX_FLAG_USE_WITNESS, &wsize);
|
||||
|
||||
assert(pull_le32(cursor, max) == tx->wtx->version);
|
||||
count = pull_length(cursor, max, 32 + 4 + 4 + 1);
|
||||
|
@ -595,6 +598,7 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
|
|||
}
|
||||
assert(pull_le32(cursor, max) == tx->wtx->locktime);
|
||||
|
||||
assert(!*cursor || oldcursor + wsize == *cursor);
|
||||
/* If we ran short, fail. */
|
||||
if (!*cursor)
|
||||
tx = tal_free(tx);
|
||||
|
|
Loading…
Add table
Reference in a new issue