summaryrefslogtreecommitdiffstats
path: root/server/red_common.h
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-09-03 19:04:16 +0300
committerAlon Levy <alevy@redhat.com>2012-09-03 19:27:22 +0300
commit1c4e315e3e8261522d4944a75e4ca3917c505d2b (patch)
treeaee87b0d57b03b8e7a3131dbd0aa2e2aa071f43a /server/red_common.h
parentf567f6b4cd696277fb48d7778d1aa0626f312d72 (diff)
downloadspice-1c4e315e3e8261522d4944a75e4ca3917c505d2b.tar.gz
spice-1c4e315e3e8261522d4944a75e4ca3917c505d2b.tar.xz
spice-1c4e315e3e8261522d4944a75e4ca3917c505d2b.zip
server/red_parse_qxl: add bitmap consistency check
Just checks stride vs width times bpp. This fixes a potential abort on guest generated bad images in glz_encoder. Other files touched to move some consts to red_common, they are static so no problem to be defined in both red_worker.c and red_parse_qxl.c .
Diffstat (limited to 'server/red_common.h')
-rw-r--r--server/red_common.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/server/red_common.h b/server/red_common.h
index c563bc03..585b13c9 100644
--- a/server/red_common.h
+++ b/server/red_common.h
@@ -25,6 +25,7 @@
#include "common/mem.h"
#include "common/spice_common.h"
#include "common/messages.h"
+#include "common/lz_common.h"
#include "spice.h"
@@ -35,13 +36,28 @@ enum {
STREAM_VIDEO_FILTER
};
+static const LzImageType MAP_BITMAP_FMT_TO_LZ_IMAGE_TYPE[] = {
+ LZ_IMAGE_TYPE_INVALID,
+ LZ_IMAGE_TYPE_PLT1_LE,
+ LZ_IMAGE_TYPE_PLT1_BE,
+ LZ_IMAGE_TYPE_PLT4_LE,
+ LZ_IMAGE_TYPE_PLT4_BE,
+ LZ_IMAGE_TYPE_PLT8,
+ LZ_IMAGE_TYPE_RGB16,
+ LZ_IMAGE_TYPE_RGB24,
+ LZ_IMAGE_TYPE_RGB32,
+ LZ_IMAGE_TYPE_RGBA,
+ LZ_IMAGE_TYPE_A8
+};
+
static inline int bitmap_fmt_is_rgb(uint8_t fmt)
{
static const int BITMAP_FMT_IS_RGB[SPICE_BITMAP_FMT_ENUM_END] =
{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
if (fmt >= SPICE_BITMAP_FMT_ENUM_END) {
- spice_warning("fmt >= SPICE_BITMAP_FMT_ENUM_END");
+ spice_warning("fmt >= SPICE_BITMAP_FMT_ENUM_END; %d >= %d",
+ fmt, SPICE_BITMAP_FMT_ENUM_END);
return 0;
}
return BITMAP_FMT_IS_RGB[fmt];