--- common/canvas_base.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/canvas_base.c b/common/canvas_base.c index cfbba5e..0f6b7f4 100644 --- a/common/canvas_base.c +++ b/common/canvas_base.c @@ -27,7 +27,6 @@ #include <math.h> #ifdef USE_LZ4 -#include <arpa/inet.h> #include <lz4.h> #endif #include <spice/macros.h> @@ -548,6 +547,18 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in } #ifdef USE_LZ4 +static inline uint32_t lz4_decode32(uint8_t *buffer) +{ + // Network order -> big endian + uint32_t value = 0; + int i; + for (i = 0; i < 4; ++i) { + value <<= 8; + value += buffer[i]; + } + return value; +} + static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int invers) { pixman_image_t *surface = NULL; @@ -587,7 +598,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int do { // Read next compressed block - enc_size = ntohl(*((uint32_t *)data)); + enc_size = lz4_decode32(data); data += 4; dec_size = LZ4_decompress_safe_continue(stream, (const char *) data, (char *) dest, enc_size, available); -- 1.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel