From a405c22fc9cffbe2a6c27a0a877db63224599817 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 17 Feb 2019 15:40:53 +0100 Subject: [PATCH] daemon: Fix issue 2348, db->filenam not being correctly initialized We were not correctly allocating the `db->filename`, failing to copy the null-terminator. This was causing and error when reopening the database after the call to `fork()`. Signed-off-by: Christian Decker Reported-by: Sean McNally <@sfmcnally> Changelog-fixed: Fixed a crash when running in daemon-mode due to db filename overrun --- wallet/db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/db.c b/wallet/db.c index 5082d593f..cf9d53ee5 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -557,7 +557,7 @@ static struct db *db_open(const tal_t *ctx, char *filename) } db = tal(ctx, struct db); - db->filename = tal_dup_arr(db, char, filename, strlen(filename), 0); + db->filename = tal_strdup(db, filename); db->sql = sql; tal_add_destructor(db, destroy_db); db->in_transaction = NULL;