core-lightning/wallet
Sebastian Falbesoner 48473eb3e9 wallet-test: fix segfault due to uninitialized block
The variable `block` (instace of `struct block`) is
allocated on the stack without being initialized, i.e. its
member `prev` points to nowhere. This causes a segmentation
fault on my machine on the binding of "prev_hash" on running
`wallet_block_add`, as the following core-dump analysis
shows:

    $ egdb ./wallet/test/run-wallet ./run-wallet.core
    [...]
    Core was generated by `run-wallet'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    ---Type <return> to continue, or q <return> to quit---
    #0  0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
    97                      TLOOP1(*dst++ = *src++);
    (gdb) bt
    #0  0x000008f67a04b660 in memcpy (dst0=<optimized out>, src0=0x100007f8c, length=32) at /usr/src/lib/libc/string/memcpy.c:97
    #1  0x000008f73e838f60 in sqlite3VdbeMemSetStr () from /usr/local/lib/libsqlite3.so.37.12
    #2  0x000008f73e83cb11 in bindText () from /usr/local/lib/libsqlite3.so.37.12
    #3  0x000008f44bc91345 in db_sqlite3_query (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:77
    #4  0x000008f44bc91122 in db_sqlite3_exec (stmt=0x8f6845bf028) at wallet/db_sqlite3.c:110
    #5  0x000008f44bcbb3b2 in db_exec_prepared_v2 (stmt=0x8f6845bf028) at ./wallet/db.c:2055
    #6  0x000008f44bcc6890 in wallet_block_add (w=0x8f688b5bba8, b=0x7f7ffffca788) at ./wallet/wallet.c:3556
    #7  0x000008f44bce2607 in test_wallet_outputs (ld=0x8f6a35a7828, ctx=0x8f6a35c0268) at wallet/test/run-wallet.c:1104
    #8  0x000008f44bcddec0 in main (argc=1, argv=0x7f7ffffcaaf8) at wallet/test/run-wallet.c:1930

Fix by explicitely setting the whole structure to zero.

[ Rebuilt generated files, too --RR ]
2021-08-23 19:46:04 +09:30
..
test wallet-test: fix segfault due to uninitialized block 2021-08-23 19:46:04 +09:30
.gitignore reorganize .gitignore entries across subdirs. 2021-05-18 09:43:50 +09:30
db_common.h
db_postgres_sqlgen.c wallet-test: fix segfault due to uninitialized block 2021-08-23 19:46:04 +09:30
db_postgres.c Makefile: make check-includes check all the non-generated files. 2020-10-22 12:14:34 +10:30
db_sqlite3_sqlgen.c wallet-test: fix segfault due to uninitialized block 2021-08-23 19:46:04 +09:30
db_sqlite3.c Makefile: make check-includes check all the non-generated files. 2020-10-22 12:14:34 +10:30
db.c channel utxo: persist the 'csv' lock value to database 2021-07-20 13:28:38 -04:00
db.h db: add helper for db_col_psbt 2020-10-20 12:50:31 +10:30
invoices.c listinvoice: populate local_offer_id when iterating whole db. 2021-07-03 12:13:45 +09:30
invoices.h invoice: add an optional local_offer_id. 2020-12-15 12:05:02 +01:00
Makefile Makefile: allow postfixes to SHA256STAMP. 2021-05-27 20:28:49 +09:30
reservation.c utxo: don't add outputs that aren't currently eligible to be spent 2021-07-20 13:28:38 -04:00
statements_gettextgen.po wallet-test: fix segfault due to uninitialized block 2021-08-23 19:46:04 +09:30
txfilter.c
txfilter.h
wallet.c utxos: more comprehensive fix for csv check 2021-08-17 13:20:00 +09:30
wallet.h chaintopology: tell gossipd that channels no longer exist on reorg. 2021-08-14 12:07:38 +09:30
walletrpc.c channel utxo: persist the 'csv' lock value to database 2021-07-20 13:28:38 -04:00
walletrpc.h common: pull up param_psbt 2020-10-20 12:50:31 +10:30