From: Hannes Reinecke Date: Tue, 13 Apr 2021 12:29:39 +0000 (+0200) Subject: fabrics: fixup hostid size X-Git-Tag: v1.0-rc0~129^2~15 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d10aab43889a3fbbd3eaa388d67b76fc37bdd1ea;p=users%2Fsagi%2Flibnvme.git fabrics: fixup hostid size 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 --- diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 52e05670..c562f9a1 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -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)