From 3c038e4171f0c4630e9b234d6bba8b5f156de2b0 Mon Sep 17 00:00:00 2001 From: darosior Date: Wed, 16 Oct 2019 15:25:19 +0200 Subject: [PATCH] hsm encryption: don't include '\n' when deriving the encryption key --- lightningd/options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightningd/options.c b/lightningd/options.c index f4112239c..7f0648dac 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -398,6 +398,8 @@ static char *opt_set_hsm_password(struct lightningd *ld) printf("Enter hsm_secret password : "); if (getline(&passwd, &passwd_size, stdin) < 0) return "Could not read password from stdin."; + if(passwd[strlen(passwd) - 1] == '\n') + passwd[strlen(passwd) - 1] = '\0'; if (tcsetattr(fileno(stdin), TCSAFLUSH, ¤t_term) != 0) return "Could not restore terminal options."; printf("\n"); @@ -416,7 +418,6 @@ static char *opt_set_hsm_password(struct lightningd *ld) crypto_pwhash_ALG_ARGON2ID13) != 0) return "Could not derive a key from the password."; free(passwd); - return NULL; }