diff options
author | runge <runge@karlrunge.com> | 2009-05-21 10:32:18 -0400 |
---|---|---|
committer | runge <runge@karlrunge.com> | 2009-05-21 10:32:18 -0400 |
commit | 804335f9d296440bb708ca844f5d89b58b50b0c6 (patch) | |
tree | a59c3c06a829b0a80c5d276d587369e01e92a5fb /libvncserver/zrle.c | |
parent | 2cd48332e02d9c81f67b2d718ad1feed5b0a808e (diff) | |
download | libtdevnc-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/zrle.c')
-rw-r--r-- | libvncserver/zrle.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libvncserver/zrle.c b/libvncserver/zrle.c index 2475fc0..e1f1447 100644 --- a/libvncserver/zrle.c +++ b/libvncserver/zrle.c @@ -97,21 +97,25 @@ */ /* TODO: put into rfbClient struct */ -static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4]; - +static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4]; /* * rfbSendRectEncodingZRLE - send a given rectangle using ZRLE encoding. */ - rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) { zrleOutStream* zos; rfbFramebufferUpdateRectHeader rect; rfbZRLEHeader hdr; int i; + char *zrleBeforeBuf; + + if (cl->zrleBeforeBuf == NULL) { + cl->zrleBeforeBuf = (char *) malloc(rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4); + } + zrleBeforeBuf = cl->zrleBeforeBuf; if (cl->preferredEncoding == rfbEncodingZYWRLE) { if (cl->tightQualityLevel < 0) { @@ -238,8 +242,19 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) void rfbFreeZrleData(rfbClientPtr cl) { - if (cl->zrleData) - zrleOutStreamFree(cl->zrleData); - cl->zrleData = NULL; + if (cl->zrleData) { + zrleOutStreamFree(cl->zrleData); + } + cl->zrleData = NULL; + + if (cl->zrleBeforeBuf) { + free(cl->zrleBeforeBuf); + } + cl->zrleBeforeBuf = NULL; + + if (cl->paletteHelper) { + free(cl->paletteHelper); + } + cl->paletteHelper = NULL; } |