]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: fixup length calculation for 'nvme gen-tls-key --secret'
authorHannes Reinecke <hare@suse.de>
Fri, 17 Nov 2023 07:11:24 +0000 (08:11 +0100)
committerDaniel Wagner <wagi@monom.org>
Fri, 17 Nov 2023 09:40:43 +0000 (10:40 +0100)
The raw secret is passed in hex, so the length of the input is
twice the size of the key.

Signed-off-by: Hannes Reinecke <hare@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index fb0afca1d3d85a2135079536fcdda8a2c4accdaf..1fb20036e17750e05e2eb90eacf0c6e9f7155173 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -8715,7 +8715,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
                                nvme_show_error("Invalid secret '%s'", cfg.secret);
                                return -EINVAL;
                        }
-                       if (i >= key_len) {
+                       if (i >= key_len * 2) {
                                fprintf(stderr, "Skipping excess secret bytes\n");
                                break;
                        }