Skip to content

Commit

Permalink
daemon: Fix issue 2348, db->filenam not being correctly initialized
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Sean McNally <@sfmcnally>
Changelog-fixed: Fixed a crash when running in daemon-mode due to db filename overrun
  • Loading branch information
cdecker committed Feb 18, 2019
1 parent 3db5345 commit a405c22
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a405c22

Please sign in to comment.