diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-03-26 13:05:45 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-04-01 14:19:09 +0200 |
commit | ce48f2f441ca98885267af6fd636a7cb804ee646 (patch) | |
tree | bd5dd8a13a805d7408162ed456389cf868f472f9 /block/qcow2.c | |
parent | 8c7de28305a514d7f879fdfc677ca11fbf60d2e9 (diff) | |
download | qemu-ce48f2f441ca98885267af6fd636a7cb804ee646.zip qemu-ce48f2f441ca98885267af6fd636a7cb804ee646.tar.gz qemu-ce48f2f441ca98885267af6fd636a7cb804ee646.tar.bz2 |
qcow2: Validate snapshot table offset/size (CVE-2014-0144)
This avoid unbounded memory allocation and fixes a potential buffer
overflow on 32 bit hosts.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r-- | block/qcow2.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 37a332f..8d0a09e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -623,6 +623,21 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } + /* Snapshot table offset/length */ + if (header.nb_snapshots > QCOW_MAX_SNAPSHOTS) { + error_setg(errp, "Too many snapshots"); + ret = -EINVAL; + goto fail; + } + + ret = validate_table_offset(bs, header.snapshots_offset, + header.nb_snapshots, + sizeof(QCowSnapshotHeader)); + if (ret < 0) { + error_setg(errp, "Invalid snapshot table offset"); + goto fail; + } + s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; |