[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/39] qemu-nbd: Shrink image size by specified offse
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 26/39] qemu-nbd: Shrink image size by specified offset |
Date: |
Fri, 7 Oct 2016 18:57:50 +0200 |
From: Tomáš Golembiovský <address@hidden>
When --offset is set the apparent device size has to be adjusted
accordingly. Otherwise client may request read/write beyond the file end
which would fail.
Signed-off-by: Tomáš Golembiovský <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-nbd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 99297a5..705b95e 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -901,6 +901,14 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
+ if (dev_offset >= fd_size) {
+ error_report("Offset (%lld) has to be smaller than the image size "
+ "(%lld)",
+ (long long int)dev_offset, (long long int)fd_size);
+ exit(EXIT_FAILURE);
+ }
+ fd_size -= dev_offset;
+
if (partition != -1) {
ret = find_partition(blk, partition, &dev_offset, &fd_size);
if (ret < 0) {
--
2.7.4
- [Qemu-devel] [PULL 16/39] cpu: atomically modify cpu->exit_request, (continued)
- [Qemu-devel] [PULL 16/39] cpu: atomically modify cpu->exit_request, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 17/39] util/qht: atomically set b->hashes, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 18/39] linux-user/syscall: extend lock around cpu-list, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 19/39] qga/command: use QEMU atomic primitives, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 20/39] .travis.yml: add gcc sanitizer build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 22/39] char: use a fixed idx for child muxed chr, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 21/39] i8259: give ISA device when registering ISA ioports, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 23/39] char: update read handler in all cases, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 25/39] qemu_kill_report: Report PID name too, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 24/39] util: Introduce qemu_get_pid_name, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 26/39] qemu-nbd: Shrink image size by specified offset,
Paolo Bonzini <=
- [Qemu-devel] [PULL 27/39] qht: simplify qht_reset_size, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 28/39] qht: fix unlock-after-free segfault upon resizing, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 30/39] qemu-tech: drop index, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 29/39] test-qht: perform lookups under rcu_read_lock, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 31/39] qemu-doc: replace introduction with the one from the internals manual, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 33/39] qemu-tech: move text from qemu-tech to tcg/README, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 32/39] qemu-doc: drop installation and compilation notes, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 36/39] qemu-tech: move TCG test documentation to tests/tcg/README, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 34/39] qemu-tech: document lazy condition code evaluation in cpu.h, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 37/39] qemu-tech: reorganize content, Paolo Bonzini, 2016/10/07