]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
fabrics: fixup hostid size
authorHannes Reinecke <hare@suse.de>
Tue, 13 Apr 2021 12:29:39 +0000 (14:29 +0200)
committerHannes Reinecke <hare@suse.de>
Fri, 11 Jun 2021 08:47:54 +0000 (10:47 +0200)
The NVMe host id is a UUID with the string length 36. As the
read() call uses the passed-in length minus one we need to
increase the host ID length by one to avoid nvmf_read_file(f,
NVMF_HOSTID_LEN) skipping the last character.

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

index 52e05670d9a9d7ed77f210c37a23454e5aeb4221..c562f9a1b23b6ef3b07421e82f176e60c4ff5b5e 100644 (file)
@@ -32,7 +32,7 @@
 #include "ioctl.h"
 #include "util.h"
 
-#define NVMF_HOSTID_SIZE       36
+#define NVMF_HOSTID_SIZE       37
 
 const char *nvmf_dev = "/dev/nvme-fabrics";
 const char *nvmf_hostnqn_file = "/etc/nvme/hostnqn";
@@ -374,7 +374,7 @@ static char *nvmf_read_file(const char *f, int len)
                return false;
 
        memset(buf, 0, len);
-       ret = read(fd, buf, sizeof(buf - 1));
+       ret = read(fd, buf, len - 1);
        close (fd);
 
        if (ret < 0)