]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: fix connecting failure due to invalid uuid format of hostid
authorGuan Junxiong <guanjunxiong@huawei.com>
Thu, 3 Aug 2017 13:38:16 +0000 (21:38 +0800)
committerKeith Busch <keith.busch@intel.com>
Thu, 10 Aug 2017 17:09:24 +0000 (13:09 -0400)
When we connect or discover a target with --hostid option via the
/etc/nvme/hostid file, we fails this operation because the hostid
is only 35 not 36 bytes which doesn't pass the uuid checking in the
kernel.The last character is overridden with null bytes because fgets
reads at most one less than sizeof of buffer characters.

Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
fabrics.c

index da4e04ebbbddedc0a842d18e3c63cbc51dd4e233..9ed11274abd0d6e9167930f93f403334af2ff0fb 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -463,7 +463,7 @@ out:
 static int nvmf_hostid_file(void)
 {
        FILE *f;
-       char hostid[NVMF_HOSTID_SIZE];
+       char hostid[NVMF_HOSTID_SIZE + 1];
        int ret = false;
 
        f = fopen(PATH_NVMF_HOSTID, "r");