qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qcow2.c: Check if backing file name length is valid
@ 2014-03-19  8:19 Deepak Kathayat
  0 siblings, 0 replies; only message in thread
From: Deepak Kathayat @ 2014-03-19  8:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Deepak Kathayat, stefanha


Signed-off-by: Deepak Kathayat <deepak.mk17@gmail.com>
---
The len variable is a signed integer whereas the backing file name
 length in the image header is unsigned. Therefore, it may
 overflow. Furthermore, backing file name length cannot be
 zero. These two cases must be handled explicitly.
 block/qcow2.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index 945c9d6..7b6f65c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -625,6 +625,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
     /* read the backing file name */
     if (header.backing_file_offset != 0) {
         len = header.backing_file_size;
+        if (len <= 0) {
+            error_setg(errp, "Invalid backing file name length: %d", len);
+            ret = -EINVAL;
+            goto fail;
+        }
         if (len > 1023) {
             len = 1023;
         }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-19  8:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-19  8:19 [Qemu-devel] [PATCH] qcow2.c: Check if backing file name length is valid Deepak Kathayat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).