summaryrefslogtreecommitdiffstats
path: root/libvncserver/zrleencodetemplate.c
diff options
context:
space:
mode:
authorrunge <runge@karlrunge.com>2009-05-21 10:32:18 -0400
committerrunge <runge@karlrunge.com>2009-05-21 10:32:18 -0400
commit804335f9d296440bb708ca844f5d89b58b50b0c6 (patch)
treea59c3c06a829b0a80c5d276d587369e01e92a5fb /libvncserver/zrleencodetemplate.c
parent2cd48332e02d9c81f67b2d718ad1feed5b0a808e (diff)
downloadlibtdevnc-804335f9d296440bb708ca844f5d89b58b50b0c6.tar.gz
libtdevnc-804335f9d296440bb708ca844f5d89b58b50b0c6.zip
Thread safety for zrle, zlib, tight.
Proposed tight security type fix for debian bug 517422.
Diffstat (limited to 'libvncserver/zrleencodetemplate.c')
-rw-r--r--libvncserver/zrleencodetemplate.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libvncserver/zrleencodetemplate.c b/libvncserver/zrleencodetemplate.c
index 6e81b3c..3a6f117 100644
--- a/libvncserver/zrleencodetemplate.c
+++ b/libvncserver/zrleencodetemplate.c
@@ -89,7 +89,7 @@ static zrlePaletteHelper paletteHelper;
#endif /* ZRLE_ONCE */
void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os,
- int zywrle_level, int *zywrleBuf);
+ int zywrle_level, int *zywrleBuf, void *paletteHelper);
#if BPP!=8
#define ZYWRLE_ENCODE
@@ -111,8 +111,12 @@ static void ZRLE_ENCODE (int x, int y, int w, int h,
GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf);
+ if (cl->paletteHelper == NULL) {
+ cl->paletteHelper = (void *) calloc(sizeof(zrlePaletteHelper), 1);
+ }
+
ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os,
- cl->zywrleLevel, cl->zywrleBuf);
+ cl->zywrleLevel, cl->zywrleBuf, cl->paletteHelper);
}
}
zrleOutStreamFlush(os);
@@ -120,7 +124,7 @@ static void ZRLE_ENCODE (int x, int y, int w, int h,
void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os,
- int zywrle_level, int *zywrleBuf)
+ int zywrle_level, int *zywrleBuf, void *paletteHelper)
{
/* First find the palette and the number of runs */
@@ -140,7 +144,11 @@ void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os,
PIXEL_T* end = ptr + h * w;
*end = ~*(end-1); /* one past the end is different so the while loop ends */
+#if 0
ph = &paletteHelper;
+#else
+ ph = (zrlePaletteHelper *) paletteHelper;
+#endif
zrlePaletteHelperInit(ph);
while (ptr < end) {
@@ -289,7 +297,7 @@ void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os,
#if BPP!=8
if (zywrle_level > 0 && !(zywrle_level & 0x80)) {
ZYWRLE_ANALYZE(data, data, w, h, w, zywrle_level, zywrleBuf);
- ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf);
+ ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf, paletteHelper);
}
else
#endif