[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 40/77] nbd: Avoid off-by-one in long export name truncation
From: |
Michael Roth |
Subject: |
[PATCH 40/77] nbd: Avoid off-by-one in long export name truncation |
Date: |
Thu, 3 Sep 2020 15:58:58 -0500 |
From: Eric Blake <eblake@redhat.com>
When snprintf returns the same value as the buffer size, the final
byte was truncated to ensure a NUL terminator. Fortunately, such long
export names are unusual enough, with no real impact other than what
is displayed to the user.
Fixes: 5c86bdf12089
Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200622210355.414941-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
(cherry picked from commit 00d69986da83a74f6f5731c80f8dd09fde95d19a)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
block/nbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/nbd.c b/block/nbd.c
index bfc0be6af6..bf3fbebfa0 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -2011,7 +2011,7 @@ static void nbd_refresh_filename(BlockDriverState *bs)
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd://%s:%s", host, port);
}
- if (len > sizeof(bs->exact_filename)) {
+ if (len >= sizeof(bs->exact_filename)) {
/* Name is too long to represent exactly, so leave it empty. */
bs->exact_filename[0] = '\0';
}
--
2.17.1
- [PATCH 24/77] aio-posix: don't duplicate fd handler deletion in fdmon_io_uring_destroy(), (continued)
- [PATCH 24/77] aio-posix: don't duplicate fd handler deletion in fdmon_io_uring_destroy(), Michael Roth, 2020/09/03
- [PATCH 25/77] aio-posix: disable fdmon-io_uring when GSource is used, Michael Roth, 2020/09/03
- [PATCH 26/77] linux-user/strace.list: fix epoll_create{, 1} -strace output, Michael Roth, 2020/09/03
- [PATCH 28/77] libqos: pci-pc: use 32-bit write for EJ register, Michael Roth, 2020/09/03
- [PATCH 27/77] libqos: usb-hcd-ehci: use 32-bit write for config register, Michael Roth, 2020/09/03
- [PATCH 29/77] memory: Revert "memory: accept mismatching sizes in memory_region_access_valid", Michael Roth, 2020/09/03
- [PATCH 02/77] target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_*, Michael Roth, 2020/09/03
- [PATCH 32/77] acpi: accept byte and word access to core ACPI registers, Michael Roth, 2020/09/03
- [PATCH 31/77] xhci: fix valid.max_access_size to access address registers, Michael Roth, 2020/09/03
- [PATCH 34/77] hw/net/e1000e: Do not abort() on invalid PSRCTL register value, Michael Roth, 2020/09/03
- [PATCH 40/77] nbd: Avoid off-by-one in long export name truncation,
Michael Roth <=
- [PATCH 33/77] hw/display/artist: Unbreak size mismatch memory accesses, Michael Roth, 2020/09/03
- [PATCH 39/77] usb/dev-mtp: Fix Error double free after inotify failure, Michael Roth, 2020/09/03
- [PATCH 03/77] qemu-nbd: Close inherited stderr, Michael Roth, 2020/09/03
- [PATCH 30/77] hw/riscv: Allow 64 bit access to SiFive CLINT, Michael Roth, 2020/09/03
- [PATCH 35/77] virtiofsd: Whitelist fchmod, Michael Roth, 2020/09/03
- [PATCH 38/77] error: Use error_reportf_err() where appropriate, Michael Roth, 2020/09/03
- [PATCH 41/77] chardev/tcp: Fix error message double free error, Michael Roth, 2020/09/03
- [PATCH 42/77] qga: fix assert regression on guest-shutdown, Michael Roth, 2020/09/03
- [PATCH 36/77] hw/audio/gus: Fix registers 32-bit access, Michael Roth, 2020/09/03
- [PATCH 37/77] net/virtio: Fix failover_replug_primary() return value regression, Michael Roth, 2020/09/03