rgb-cln/db
Matt Morehouse 45cb2b149c db: avoid calling memcpy on NULL
It is possible for db_column_bytes() to return 0 and for
db_column_blob() to return NULL even when db_column_is_null() returns
false. We need to short circuit in this case.

Detected by UBSan:

  db/bindings.c:479:12: runtime error: null pointer passed as argument 2, which is declared to never be null
  /usr/include/string.h:44:28: note: nonnull attribute specified here

  #0 0x95f117 in db_col_arr_ db/bindings.c:479:2
  #1 0x95ef85 in db_col_channel_type db/bindings.c:459:32
  #2 0x852c03 in wallet_stmt2channel wallet/wallet.c:1483:9
  #3 0x81f396 in wallet_channels_load_active wallet/wallet.c:1749:23
  #4 0x81f03d in wallet_init_channels wallet/wallet.c:1765:9
  #5 0x72f1f9 in load_channels_from_wallet lightningd/peer_control.c:2257:7
  #6 0x672856 in main lightningd/lightningd.c:1121:25
2023-06-05 16:16:21 +02:00
..
Makefile database: pull out database code into a new module 2022-03-05 15:03:34 +10:30
bindings.c db: avoid calling memcpy on NULL 2023-06-05 16:16:21 +02:00
bindings.h wallet: add channel_type field to db. 2023-04-10 17:26:47 +09:30
common.h database: pull out database code into a new module 2022-03-05 15:03:34 +10:30
db_postgres.c db/postgres: avoid memleak. 2022-09-22 15:19:46 +02:00
db_sqlite3.c db: fix sqlite3 code which manipulates columns. 2022-09-12 14:00:41 +02:00
exec.c db: db_set_intvar/db_get_var should take a const char *. 2023-04-06 09:50:32 +09:30
exec.h db: db_set_intvar/db_get_var should take a const char *. 2023-04-06 09:50:32 +09:30
utils.c db: print nice message and not just backtrace on bad column name. 2023-04-10 17:26:47 +09:30
utils.h db: make db_exec_prepared_v2 return void. 2023-04-06 09:50:32 +09:30