Re: [PATCH] server/red_parse_qxl: add bitmap consistency check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/03/2012 07:24 PM, Alon Levy wrote:
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 .

Hi Alon,

I think it's better to share this const array by making it non-static, and
declare it as an extern in red_common.h

Moving the static const array to red_common.h makes each
source file contain it's own copy of the array.

Regards,
    Uri.
---
  server/red_common.h    | 18 +++++++++++++++++-
  server/red_parse_qxl.c | 17 +++++++++++++++++
  server/red_worker.c    | 15 ---------------
  3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/server/red_common.h b/server/red_common.h
index c563bc0..585b13c 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];


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]