Stefan Hajnoczi f0dce23475 dmg: prevent chunk buffer overflow (CVE-2014-0145)
Both compressed and uncompressed I/O is buffered.  dmg_open() calculates
the maximum buffer size needed from the metadata in the image file.

There is currently a buffer overflow since ->lengths[] is accounted
against the maximum compressed buffer size but actually uses the
uncompressed buffer:

  switch (s->types[chunk]) {
  case 1: /* copy */
      ret = bdrv_pread(bs->file, s->offsets[chunk],
                       s->uncompressed_chunk, s->lengths[chunk]);

We must account against the maximum uncompressed buffer size for type=1
chunks.

This patch fixes the maximum buffer size calculation to take into
account the chunk type.  It is critical that we update the correct
maximum since there are two buffers ->compressed_chunk and
->uncompressed_chunk.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-04-01 15:22:35 +02:00
..
2014-04-01 13:59:47 +02:00
2013-12-20 16:26:16 +01:00
2014-02-21 21:02:24 +01:00
2014-03-25 14:09:50 +01:00
2013-08-19 15:52:19 +02:00
2014-02-25 10:50:11 +00:00
2014-02-21 21:02:22 +01:00
2014-03-19 09:39:41 +01:00
2014-02-21 21:02:24 +01:00
2014-02-17 11:57:23 -05:00
2014-03-25 14:09:50 +01:00
2014-02-17 11:57:23 -05:00
2014-03-25 14:09:50 +01:00
2013-09-12 10:12:48 +02:00
2014-03-25 14:09:50 +01:00
2014-04-01 13:59:47 +02:00