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/zlib.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/zlib.c')
-rw-r--r-- | libvncserver/zlib.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libvncserver/zlib.c b/libvncserver/zlib.c index 7b20f74..ac20c9c 100644 --- a/libvncserver/zlib.c +++ b/libvncserver/zlib.c @@ -40,12 +40,24 @@ * raw encoding is used instead. */ -static int zlibBeforeBufSize = 0; -static char *zlibBeforeBuf = NULL; - -static int zlibAfterBufSize = 0; -static char *zlibAfterBuf = NULL; -static int zlibAfterBufLen; +/* + * Out of lazyiness, we use thread local storage for zlib as we did for + * tight. N.B. ZRLE does it the traditional way with per-client storage + * (and so at least ZRLE will work threaded on older systems.) + */ +#if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS && !defined(TLS) && defined(__linux__) +#define TLS __thread +#endif +#ifndef TLS +#define TLS +#endif + +static TLS int zlibBeforeBufSize = 0; +static TLS char *zlibBeforeBuf = NULL; + +static TLS int zlibAfterBufSize = 0; +static TLS char *zlibAfterBuf = NULL; +static TLS int zlibAfterBufLen = 0; void rfbZlibCleanup(rfbScreenInfoPtr screen) { |