From d478dc0e59bb5dbe452d6eaec00c7ff5462fbe52 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 17 Feb 2020 10:18:49 +1030 Subject: [PATCH] wallet: fix null column access for pre-0.7.3 dbs. Added in d901304120, this column is null in old dbs like mine: 2020-02-15T00:08:41.444Z **BROKEN** database: Accessing a null column 12 in query SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time FROM channel_htlcs WHERE direction= ? AND channel_id= ? AND hstate != ? Signed-off-by: Rusty Russell --- Makefile | 2 +- wallet/wallet.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7f49817de..db4d3e587 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ endif ifeq ($(COMPAT),1) # We support compatibility with pre-0.6. -COMPAT_CFLAGS=-DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 +COMPAT_CFLAGS=-DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 endif # Timeout shortly before the 600 second travis silence timeout diff --git a/wallet/wallet.c b/wallet/wallet.c index 72361a6a7..61c80ddb7 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1831,6 +1831,12 @@ static bool wallet_stmt2htlc_in(struct channel *channel, #endif } +#ifdef COMPAT_V072 + if (db_column_is_null(stmt, 12)) { + in->received_time.ts.tv_sec = 0; + in->received_time.ts.tv_nsec = 0; + } else +#endif /* COMPAT_V072 */ in->received_time = db_column_timeabs(stmt, 12); return ok;