Skip to content

Commit f46b064

Browse files
martin-gpyigaw
authored andcommitted
linux: avoid segfault in check-tls-key due to null hostnqn/subsysnqn
Running nvme check-tls-key hits a segfault as seen below: nvme check-tls-key -d NVMeTLSkey-1:01:bB7soUnpHfxVg53sCY21KY3nLbqLit2RcIO8Rbdf3mKhcKaM: Segmentation fault (core dumped) This is because the strlen check on subsysnqn or hostnqn crashes at src/nvme/linux.c due to either of them being null. Avoid this segfault by checking these strings before running a strlen on them. Signed-off-by: Martin George <[email protected]>
1 parent 11d0a89 commit f46b064

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/nvme/linux.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,11 @@ static size_t nvme_identity_len(int hmac, int version, const char *hostnqn,
11041104
{
11051105
size_t len;
11061106

1107+
if (!hostnqn || !subsysnqn) {
1108+
errno = EINVAL;
1109+
return -1;
1110+
}
1111+
11071112
len = strlen(hostnqn) + strlen(subsysnqn) + 12;
11081113
if (version == 1) {
11091114
len += 66;

0 commit comments

Comments
 (0)