diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-03-02 14:33:50 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-03-18 13:30:34 +0100 |
commit | 19df176862ff0687cabc435056061a1b6cbe9ff2 (patch) | |
tree | a76c497fa8c7128ea2651f48fd170d8963b007db | |
parent | 15a0da6157d5d34362e68591124324ba5a77ad66 (diff) | |
download | tigervnc-19df176862ff0687cabc435056061a1b6cbe9ff2.tar.gz tigervnc-19df176862ff0687cabc435056061a1b6cbe9ff2.zip |
Consistently use uint8_t for data buffers
These will always be byte streams at heart, so let's try to keep them
with a proper type. Should make it clearer how they will be used.
52 files changed, 108 insertions, 99 deletions
diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx index 4ddd1221..8e12f3a4 100644 --- a/common/rdr/FdInStream.cxx +++ b/common/rdr/FdInStream.cxx @@ -77,7 +77,7 @@ bool FdInStream::fillBuffer() // returning EINTR. // -size_t FdInStream::readFd(void* buf, size_t len) +size_t FdInStream::readFd(uint8_t* buf, size_t len) { int n; do { diff --git a/common/rdr/FdInStream.h b/common/rdr/FdInStream.h index 71370a59..0f8373fe 100644 --- a/common/rdr/FdInStream.h +++ b/common/rdr/FdInStream.h @@ -39,7 +39,7 @@ namespace rdr { private: virtual bool fillBuffer(); - size_t readFd(void* buf, size_t len); + size_t readFd(uint8_t* buf, size_t len); int fd; bool closeWhenDone; diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx index e630a4d7..3a8cb076 100644 --- a/common/rdr/FdOutStream.cxx +++ b/common/rdr/FdOutStream.cxx @@ -78,7 +78,7 @@ void FdOutStream::cork(bool enable) bool FdOutStream::flushBuffer() { - size_t n = writeFd((const void*) sentUpTo, ptr - sentUpTo); + size_t n = writeFd(sentUpTo, ptr - sentUpTo); if (n == 0) return false; @@ -96,7 +96,7 @@ bool FdOutStream::flushBuffer() // returning EINTR. // -size_t FdOutStream::writeFd(const void* data, size_t length) +size_t FdOutStream::writeFd(const uint8_t* data, size_t length) { int n; diff --git a/common/rdr/FdOutStream.h b/common/rdr/FdOutStream.h index 80804da4..05fc1fed 100644 --- a/common/rdr/FdOutStream.h +++ b/common/rdr/FdOutStream.h @@ -45,7 +45,7 @@ namespace rdr { private: virtual bool flushBuffer(); - size_t writeFd(const void* data, size_t length); + size_t writeFd(const uint8_t* data, size_t length); int fd; struct timeval lastWrite; }; diff --git a/common/rdr/InStream.h b/common/rdr/InStream.h index c6c83456..019ca5a7 100644 --- a/common/rdr/InStream.h +++ b/common/rdr/InStream.h @@ -145,7 +145,7 @@ namespace rdr { // readBytes() reads an exact number of bytes. - void readBytes(void* data, size_t length) { + void readBytes(uint8_t* data, size_t length) { check(length); memcpy(data, ptr, length); ptr += length; diff --git a/common/rdr/MemInStream.h b/common/rdr/MemInStream.h index 08f48392..61d08482 100644 --- a/common/rdr/MemInStream.h +++ b/common/rdr/MemInStream.h @@ -36,8 +36,8 @@ namespace rdr { public: - MemInStream(const void* data, size_t len, bool deleteWhenDone_=false) - : start((const uint8_t*)data), deleteWhenDone(deleteWhenDone_) + MemInStream(const uint8_t* data, size_t len, bool deleteWhenDone_=false) + : start(data), deleteWhenDone(deleteWhenDone_) { ptr = start; end = start + len; diff --git a/common/rdr/MemOutStream.h b/common/rdr/MemOutStream.h index 33920a4d..5ed1ccf7 100644 --- a/common/rdr/MemOutStream.h +++ b/common/rdr/MemOutStream.h @@ -48,7 +48,7 @@ namespace rdr { // data() returns a pointer to the buffer. - const void* data() { return (const void*)start; } + const uint8_t* data() { return start; } protected: diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h index 70216a2d..8450efd0 100644 --- a/common/rdr/OutStream.h +++ b/common/rdr/OutStream.h @@ -70,7 +70,7 @@ namespace rdr { // writeBytes() writes an exact number of bytes. - void writeBytes(const void* data, size_t length) { + void writeBytes(const uint8_t* data, size_t length) { while (length > 0) { check(1); size_t n = length; diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx index f62d6d87..7ba98155 100644 --- a/common/rdr/TLSInStream.cxx +++ b/common/rdr/TLSInStream.cxx @@ -53,7 +53,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size) if (in->avail() < size) size = in->avail(); - in->readBytes(data, size); + in->readBytes((uint8_t*)data, size); } catch (EndOfStream&) { return 0; } catch (SystemException &e) { diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx index 0a88d18a..a06dd285 100644 --- a/common/rdr/TLSOutStream.cxx +++ b/common/rdr/TLSOutStream.cxx @@ -44,7 +44,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data, self->saved_exception = NULL; try { - out->writeBytes(data, size); + out->writeBytes((const uint8_t*)data, size); out->flush(); } catch (SystemException &e) { vlog.error("Failure sending TLS data: %s", e.str()); diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index 521649ac..c07df216 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -163,7 +163,7 @@ bool CConnection::processVersionMsg() if (!is->hasData(12)) return false; - is->readBytes(verStr, 12); + is->readBytes((uint8_t*)verStr, 12); verStr[12] = '\0'; if (sscanf(verStr, "RFB %03d.%03d\n", @@ -192,7 +192,7 @@ bool CConnection::processVersionMsg() sprintf(verStr, "RFB %03d.%03d\n", server.majorVersion, server.minorVersion); - os->writeBytes(verStr, 12); + os->writeBytes((const uint8_t*)verStr, 12); os->flush(); state_ = RFBSTATE_SECURITY_TYPES; @@ -361,7 +361,7 @@ bool CConnection::processSecurityReasonMsg() is->clearRestorePoint(); std::vector<char> reason(len + 1); - is->readBytes(reason.data(), len); + is->readBytes((uint8_t*)reason.data(), len); reason[len] = '\0'; state_ = RFBSTATE_INVALID; @@ -747,7 +747,7 @@ void CConnection::setPF(const PixelFormat& pf) formatChange = true; } -void CConnection::fence(uint32_t flags, unsigned len, const char data[]) +void CConnection::fence(uint32_t flags, unsigned len, const uint8_t data[]) { CMsgHandler::fence(flags, len, data); diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h index 71da175e..df0fbb14 100644 --- a/common/rfb/CConnection.h +++ b/common/rfb/CConnection.h @@ -249,7 +249,7 @@ namespace rfb { // responds to requests, stating no support for synchronisation. // When overriding, call CMsgHandler::fence() directly in order to // state correct support for fence flags. - virtual void fence(uint32_t flags, unsigned len, const char data[]); + virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]); private: bool processVersionMsg(); diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx index e37811f9..c3594af9 100644 --- a/common/rfb/CMsgHandler.cxx +++ b/common/rfb/CMsgHandler.cxx @@ -70,7 +70,7 @@ void CMsgHandler::setName(const char* name) } void CMsgHandler::fence(uint32_t /*flags*/, unsigned /*len*/, - const char /*data*/ []) + const uint8_t /*data*/ []) { server.supportsFence = true; } diff --git a/common/rfb/CMsgHandler.h b/common/rfb/CMsgHandler.h index c427749f..16a53c6a 100644 --- a/common/rfb/CMsgHandler.h +++ b/common/rfb/CMsgHandler.h @@ -55,7 +55,7 @@ namespace rfb { virtual void setCursorPos(const Point& pos) = 0; virtual void setPixelFormat(const PixelFormat& pf); virtual void setName(const char* name); - virtual void fence(uint32_t flags, unsigned len, const char data[]); + virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]); virtual void endOfContinuousUpdates(); virtual void supportsQEMUKeyEvent(); virtual void serverInit(int width, int height, diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx index be5133cf..c0a96690 100644 --- a/common/rfb/CMsgReader.cxx +++ b/common/rfb/CMsgReader.cxx @@ -74,7 +74,7 @@ bool CMsgReader::readServerInit() return false; is->clearRestorePoint(); std::vector<char> name(len + 1); - is->readBytes(name.data(), len); + is->readBytes((uint8_t*)name.data(), len); name[len] = '\0'; handler->serverInit(width, height, pf, name.data()); @@ -276,7 +276,7 @@ bool CMsgReader::readServerCutText() return true; } std::vector<char> ca(len); - is->readBytes(ca.data(), len); + is->readBytes((uint8_t*)ca.data(), len); std::string filtered(convertLF(ca.data(), len)); handler->serverCutText(filtered.c_str()); @@ -409,7 +409,7 @@ bool CMsgReader::readFence() { uint32_t flags; uint8_t len; - char data[64]; + uint8_t data[64]; if (!is->hasData(3 + 4 + 1)) return false; @@ -763,7 +763,7 @@ bool CMsgReader::readSetDesktopName(int x, int y, int w, int h) is->clearRestorePoint(); std::vector<char> name(len + 1); - is->readBytes(name.data(), len); + is->readBytes((uint8_t*)name.data(), len); name[len] = '\0'; if (x || y || w || h) { diff --git a/common/rfb/CMsgWriter.cxx b/common/rfb/CMsgWriter.cxx index 246c5dbe..0ff81926 100644 --- a/common/rfb/CMsgWriter.cxx +++ b/common/rfb/CMsgWriter.cxx @@ -130,7 +130,7 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable, endMsg(); } -void CMsgWriter::writeFence(uint32_t flags, unsigned len, const char data[]) +void CMsgWriter::writeFence(uint32_t flags, unsigned len, const uint8_t data[]) { if (!server->supportsFence) throw Exception("Server does not support fences"); @@ -200,7 +200,7 @@ void CMsgWriter::writeClientCutText(const char* str) startMsg(msgTypeClientCutText); os->pad(3); os->writeU32(len); - os->writeBytes(str, len); + os->writeBytes((const uint8_t*)str, len); endMsg(); } diff --git a/common/rfb/CMsgWriter.h b/common/rfb/CMsgWriter.h index 7e7a9a17..1b70a1d0 100644 --- a/common/rfb/CMsgWriter.h +++ b/common/rfb/CMsgWriter.h @@ -51,7 +51,7 @@ namespace rfb { void writeFramebufferUpdateRequest(const Rect& r,bool incremental); void writeEnableContinuousUpdates(bool enable, int x, int y, int w, int h); - void writeFence(uint32_t flags, unsigned len, const char data[]); + void writeFence(uint32_t flags, unsigned len, const uint8_t data[]); void writeKeyEvent(uint32_t keysym, uint32_t keycode, bool down); void writePointerEvent(const Point& pos, int buttonMask); diff --git a/common/rfb/CSecurityDH.cxx b/common/rfb/CSecurityDH.cxx index 9e67885c..f6e5ded4 100644 --- a/common/rfb/CSecurityDH.cxx +++ b/common/rfb/CSecurityDH.cxx @@ -130,7 +130,7 @@ void CSecurityDH::writeCredentials() struct aes128_ctx aesCtx; aes128_set_encrypt_key(&aesCtx, key); - char buf[128]; + uint8_t buf[128]; if (!rs.hasData(128)) throw ConnFailedException("failed to generate random padding"); rs.readBytes(buf, 128); @@ -140,7 +140,7 @@ void CSecurityDH::writeCredentials() if (password.size() >= 64) throw AuthFailureException("password is too long"); memcpy(buf + 64, password.c_str(), password.size() + 1); - aes128_encrypt(&aesCtx, 128, (uint8_t *)buf, (uint8_t *)buf); + aes128_encrypt(&aesCtx, 128, buf, buf); rdr::OutStream* os = cc->getOutStream(); os->writeBytes(buf, 128); diff --git a/common/rfb/CSecurityPlain.cxx b/common/rfb/CSecurityPlain.cxx index 7b75ef86..d9599f9c 100644 --- a/common/rfb/CSecurityPlain.cxx +++ b/common/rfb/CSecurityPlain.cxx @@ -41,8 +41,8 @@ bool CSecurityPlain::processMsg() // Return the response to the server os->writeU32(username.size()); os->writeU32(password.size()); - os->writeBytes(username.data(), username.size()); - os->writeBytes(password.data(), password.size()); + os->writeBytes((const uint8_t*)username.data(), username.size()); + os->writeBytes((const uint8_t*)password.data(), password.size()); os->flush(); return true; } diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx index 6194caab..5a4bc9c9 100644 --- a/common/rfb/CSecurityRSAAES.cxx +++ b/common/rfb/CSecurityRSAAES.cxx @@ -445,7 +445,7 @@ void CSecurityRSAAES::writeCredentials() if (username.size() > 255) throw AuthFailureException("username is too long"); raos->writeU8(username.size()); - raos->writeBytes(username.data(), username.size()); + raos->writeBytes((const uint8_t*)username.data(), username.size()); } else { raos->writeU8(0); } @@ -453,6 +453,6 @@ void CSecurityRSAAES::writeCredentials() if (password.size() > 255) throw AuthFailureException("password is too long"); raos->writeU8(password.size()); - raos->writeBytes(password.data(), password.size()); + raos->writeBytes((const uint8_t*)password.data(), password.size()); raos->flush(); } diff --git a/common/rfb/CopyRectDecoder.cxx b/common/rfb/CopyRectDecoder.cxx index fb05dcbd..a7383881 100644 --- a/common/rfb/CopyRectDecoder.cxx +++ b/common/rfb/CopyRectDecoder.cxx @@ -49,7 +49,7 @@ bool CopyRectDecoder::readRect(const Rect& /*r*/, void CopyRectDecoder::getAffectedRegion(const Rect& rect, - const void* buffer, + const uint8_t* buffer, size_t buflen, const ServerParams& server, Region* region) @@ -64,7 +64,7 @@ void CopyRectDecoder::getAffectedRegion(const Rect& rect, srcY-rect.tl.y)))); } -void CopyRectDecoder::decodeRect(const Rect& r, const void* buffer, +void CopyRectDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& /*server*/, ModifiablePixelBuffer* pb) diff --git a/common/rfb/CopyRectDecoder.h b/common/rfb/CopyRectDecoder.h index 5100eb2f..c9f9c890 100644 --- a/common/rfb/CopyRectDecoder.h +++ b/common/rfb/CopyRectDecoder.h @@ -28,10 +28,10 @@ namespace rfb { virtual ~CopyRectDecoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void getAffectedRegion(const Rect& rect, const void* buffer, + virtual void getAffectedRegion(const Rect& rect, const uint8_t* buffer, size_t buflen, const ServerParams& server, Region* region); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); }; diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx index 832d8cf0..78c54ec3 100644 --- a/common/rfb/Decoder.cxx +++ b/common/rfb/Decoder.cxx @@ -46,7 +46,7 @@ Decoder::~Decoder() } void Decoder::getAffectedRegion(const Rect& rect, - const void* /*buffer*/, + const uint8_t* /*buffer*/, size_t /*buflen*/, const ServerParams& /*server*/, Region* region) @@ -55,10 +55,10 @@ void Decoder::getAffectedRegion(const Rect& rect, } bool Decoder::doRectsConflict(const Rect& /*rectA*/, - const void* /*bufferA*/, + const uint8_t* /*bufferA*/, size_t /*buflenA*/, const Rect& /*rectB*/, - const void* /*bufferB*/, + const uint8_t* /*bufferB*/, size_t /*buflenB*/, const ServerParams& /*server*/) { diff --git a/common/rfb/Decoder.h b/common/rfb/Decoder.h index cb206a0d..77987737 100644 --- a/common/rfb/Decoder.h +++ b/common/rfb/Decoder.h @@ -19,6 +19,8 @@ #ifndef __RFB_DECODER_H__ #define __RFB_DECODER_H__ +#include <stdint.h> + namespace rdr { class InStream; class OutStream; @@ -62,7 +64,7 @@ namespace rfb { // getAffectedRegion() returns the parts of the frame buffer will // be either read from or written do when decoding this rect. The // default implementation simply returns the given rectangle. - virtual void getAffectedRegion(const Rect& rect, const void* buffer, + virtual void getAffectedRegion(const Rect& rect, const uint8_t* buffer, size_t buflen, const ServerParams& server, Region* region); @@ -70,10 +72,10 @@ namespace rfb { // in the order they were received. This will only be called if the // DecoderPartiallyOrdered flag has been set. virtual bool doRectsConflict(const Rect& rectA, - const void* bufferA, + const uint8_t* bufferA, size_t buflenA, const Rect& rectB, - const void* bufferB, + const uint8_t* bufferB, size_t buflenB, const ServerParams& server); @@ -81,7 +83,7 @@ namespace rfb { // given buffer, onto the ModifiablePixelBuffer. The PixelFormat of // the PixelBuffer might not match the ConnParams and it is up to // the decoder to do any necessary conversion. - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb)=0; diff --git a/common/rfb/H264Decoder.cxx b/common/rfb/H264Decoder.cxx index 9de73422..f18554ef 100644 --- a/common/rfb/H264Decoder.cxx +++ b/common/rfb/H264Decoder.cxx @@ -93,7 +93,7 @@ bool H264Decoder::readRect(const Rect& /*r*/, return true; } -void H264Decoder::decodeRect(const Rect& r, const void* buffer, +void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& /*server*/, ModifiablePixelBuffer* pb) diff --git a/common/rfb/H264Decoder.h b/common/rfb/H264Decoder.h index cfb8e05c..b4f5553e 100644 --- a/common/rfb/H264Decoder.h +++ b/common/rfb/H264Decoder.h @@ -35,7 +35,7 @@ namespace rfb { virtual ~H264Decoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx index f7cbc46a..2243d67f 100644 --- a/common/rfb/HextileDecoder.cxx +++ b/common/rfb/HextileDecoder.cxx @@ -113,7 +113,7 @@ bool HextileDecoder::readRect(const Rect& r, rdr::InStream* is, return true; } -void HextileDecoder::decodeRect(const Rect& r, const void* buffer, +void HextileDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb) { @@ -158,7 +158,7 @@ void HextileDecoder::hextileDecode(const Rect& r, rdr::InStream* is, int tileType = is->readU8(); if (tileType & hextileRaw) { - is->readBytes(buf, t.area() * sizeof(T)); + is->readBytes((uint8_t*)buf, t.area() * sizeof(T)); pb->imageRect(pf, t, buf); continue; } diff --git a/common/rfb/HextileDecoder.h b/common/rfb/HextileDecoder.h index e8961d73..9163b5bb 100644 --- a/common/rfb/HextileDecoder.h +++ b/common/rfb/HextileDecoder.h @@ -31,7 +31,7 @@ namespace rfb { virtual ~HextileDecoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); private: diff --git a/common/rfb/HextileEncoder.cxx b/common/rfb/HextileEncoder.cxx index 90e59962..a63cf1fb 100644 --- a/common/rfb/HextileEncoder.cxx +++ b/common/rfb/HextileEncoder.cxx @@ -161,7 +161,8 @@ void HextileEncoder::hextileEncode(rdr::OutStream* os, if (encodedLen < 0) { pb->getImage(buf, t); os->writeU8(hextileRaw); - os->writeBytes(buf, t.width() * t.height() * sizeof(T)); + os->writeBytes((const uint8_t*)buf, + t.width() * t.height() * sizeof(T)); oldBgValid = oldFgValid = false; continue; } @@ -557,7 +558,8 @@ void HextileEncoder::hextileEncodeBetter(rdr::OutStream* os, if ( (tileType & hextileRaw) != 0 || encodedLen >= t.width() * t.height() * sizeof(T)) { os->writeU8(hextileRaw); - os->writeBytes(buf, t.width() * t.height() * sizeof(T)); + os->writeBytes((const uint8_t*)buf, + t.width() * t.height() * sizeof(T)); oldBgValid = oldFgValid = false; continue; } diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx index d5c5fd0d..a4dd5f39 100644 --- a/common/rfb/JpegCompressor.cxx +++ b/common/rfb/JpegCompressor.cxx @@ -254,7 +254,7 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride, delete[] rowPointer; } -void JpegCompressor::writeBytes(const void* /*data*/, int /*length*/) +void JpegCompressor::writeBytes(const uint8_t* /*data*/, int /*length*/) { throw rdr::Exception("writeBytes() is not valid with a JpegCompressor instance. Use compress() instead."); } diff --git a/common/rfb/JpegCompressor.h b/common/rfb/JpegCompressor.h index d4978fdf..26194204 100644 --- a/common/rfb/JpegCompressor.h +++ b/common/rfb/JpegCompressor.h @@ -45,7 +45,7 @@ namespace rfb { void compress(const uint8_t *, int, const Rect&, const PixelFormat&, int, int); - void writeBytes(const void*, int); + void writeBytes(const uint8_t*, int); private: diff --git a/common/rfb/RREDecoder.cxx b/common/rfb/RREDecoder.cxx index c85c015c..41bf501a 100644 --- a/common/rfb/RREDecoder.cxx +++ b/common/rfb/RREDecoder.cxx @@ -66,7 +66,7 @@ bool RREDecoder::readRect(const Rect& /*r*/, rdr::InStream* is, return true; } -void RREDecoder::decodeRect(const Rect& r, const void* buffer, +void RREDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb) { diff --git a/common/rfb/RREDecoder.h b/common/rfb/RREDecoder.h index 05acbc24..a1d7f9b8 100644 --- a/common/rfb/RREDecoder.h +++ b/common/rfb/RREDecoder.h @@ -31,7 +31,7 @@ namespace rfb { virtual ~RREDecoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); private: diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx index a86696e9..f2ea586b 100644 --- a/common/rfb/RawDecoder.cxx +++ b/common/rfb/RawDecoder.cxx @@ -46,7 +46,7 @@ bool RawDecoder::readRect(const Rect& r, rdr::InStream* is, return true; } -void RawDecoder::decodeRect(const Rect& r, const void* buffer, +void RawDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb) { diff --git a/common/rfb/RawDecoder.h b/common/rfb/RawDecoder.h index 2661ea57..33948ced 100644 --- a/common/rfb/RawDecoder.h +++ b/common/rfb/RawDecoder.h @@ -27,7 +27,7 @@ namespace rfb { virtual ~RawDecoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); }; diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index e5d40e9d..2b18d8c1 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -88,7 +88,7 @@ void SConnection::initialiseProtocol() char str[13]; sprintf(str, "RFB %03d.%03d\n", defaultMajorVersion, defaultMinorVersion); - os->writeBytes(str, 12); + os->writeBytes((const uint8_t*)str, 12); os->flush(); state_ = RFBSTATE_PROTOCOL_VERSION; @@ -126,7 +126,7 @@ bool SConnection::processVersionMsg() if (!is->hasData(12)) return false; - is->readBytes(verStr, 12); + is->readBytes((uint8_t*)verStr, 12); verStr[12] = '\0'; if (sscanf(verStr, "RFB %03d.%03d\n", @@ -298,7 +298,8 @@ bool SConnection::handleAuthFailureTimeout(Timer* /*t*/) os->writeU32(secResultFailed); if (!client.beforeVersion(3,8)) { // 3.8 onwards have failure message os->writeU32(authFailureMsg.size()); - os->writeBytes(authFailureMsg.data(), authFailureMsg.size()); + os->writeBytes((const uint8_t*)authFailureMsg.data(), + authFailureMsg.size()); } os->flush(); } catch (rdr::Exception& e) { @@ -326,12 +327,12 @@ void SConnection::throwConnFailedException(const char* format, ...) if (client.majorVersion == 3 && client.minorVersion == 3) { os->writeU32(0); os->writeU32(strlen(str)); - os->writeBytes(str, strlen(str)); + os->writeBytes((const uint8_t*)str, strlen(str)); os->flush(); } else { os->writeU8(0); os->writeU32(strlen(str)); - os->writeBytes(str, strlen(str)); + os->writeBytes((const uint8_t*)str, strlen(str)); os->flush(); } } @@ -467,7 +468,7 @@ void SConnection::approveConnection(bool accept, const char* reason) if (!reason) reason = "Authentication failure"; os->writeU32(strlen(reason)); - os->writeBytes(reason, strlen(reason)); + os->writeBytes((const uint8_t*)reason, strlen(reason)); } } os->flush(); @@ -519,7 +520,8 @@ void SConnection::framebufferUpdateRequest(const Rect& /*r*/, } } -void SConnection::fence(uint32_t flags, unsigned len, const char data[]) +void SConnection::fence(uint32_t flags, unsigned len, + const uint8_t data[]) { if (!(flags & fenceFlagRequest)) return; diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h index 08574069..b163d627 100644 --- a/common/rfb/SConnection.h +++ b/common/rfb/SConnection.h @@ -132,7 +132,7 @@ namespace rfb { // it responds directly to requests (stating it doesn't support any // synchronisation) and drops responses. Override to implement more proper // support. - virtual void fence(uint32_t flags, unsigned len, const char data[]); + virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]); // enableContinuousUpdates() is called when the client wants to enable // or disable continuous updates, or change the active area. diff --git a/common/rfb/SMsgHandler.h b/common/rfb/SMsgHandler.h index ec8040d2..20dc066f 100644 --- a/common/rfb/SMsgHandler.h +++ b/common/rfb/SMsgHandler.h @@ -51,7 +51,7 @@ namespace rfb { virtual void framebufferUpdateRequest(const Rect& r, bool incremental) = 0; virtual void setDesktopSize(int fb_width, int fb_height, const ScreenSet& layout) = 0; - virtual void fence(uint32_t flags, unsigned len, const char data[]) = 0; + virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]) = 0; virtual void enableContinuousUpdates(bool enable, int x, int y, int w, int h) = 0; diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx index 8cd8d147..68c9365b 100644 --- a/common/rfb/SMsgReader.cxx +++ b/common/rfb/SMsgReader.cxx @@ -229,7 +229,7 @@ bool SMsgReader::readFence() { uint32_t flags; uint8_t len; - char data[64]; + uint8_t data[64]; if (!is->hasData(3 + 4 + 1)) return false; @@ -315,7 +315,7 @@ bool SMsgReader::readClientCutText() } std::vector<char> ca(len); - is->readBytes(ca.data(), len); + is->readBytes((uint8_t*)ca.data(), len); std::string filtered(convertLF(ca.data(), len)); handler->clientCutText(filtered.c_str()); diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx index 1172ac4d..95f85352 100644 --- a/common/rfb/SMsgWriter.cxx +++ b/common/rfb/SMsgWriter.cxx @@ -63,7 +63,7 @@ void SMsgWriter::writeServerInit(uint16_t width, uint16_t height, os->writeU16(height); pf.write(os); os->writeU32(strlen(name)); - os->writeBytes(name, strlen(name)); + os->writeBytes((const uint8_t*)name, strlen(name)); endMsg(); } @@ -101,7 +101,7 @@ void SMsgWriter::writeServerCutText(const char* str) startMsg(msgTypeServerCutText); os->pad(3); os->writeU32(len); - os->writeBytes(str, len); + os->writeBytes((const uint8_t*)str, len); endMsg(); } @@ -211,7 +211,8 @@ void SMsgWriter::writeClipboardProvide(uint32_t flags, endMsg(); } -void SMsgWriter::writeFence(uint32_t flags, unsigned len, const char data[]) +void SMsgWriter::writeFence(uint32_t flags, unsigned len, + const uint8_t data[]) { if (!client->supportsEncoding(pseudoEncodingFence)) throw Exception("Client does not support fences"); @@ -585,12 +586,13 @@ void SMsgWriter::writeSetDesktopNameRect(const char *name) os->writeU16(0); os->writeU32(pseudoEncodingDesktopName); os->writeU32(strlen(name)); - os->writeBytes(name, strlen(name)); + os->writeBytes((const uint8_t*)name, strlen(name)); } void SMsgWriter::writeSetCursorRect(int width, int height, int hotspotX, int hotspotY, - const void* data, const void* mask) + const uint8_t* data, + const uint8_t* mask) { if (!client->supportsEncoding(pseudoEncodingCursor)) throw Exception("Client does not support local cursors"); @@ -608,7 +610,8 @@ void SMsgWriter::writeSetCursorRect(int width, int height, void SMsgWriter::writeSetXCursorRect(int width, int height, int hotspotX, int hotspotY, - const void* data, const void* mask) + const uint8_t* data, + const uint8_t* mask) { if (!client->supportsEncoding(pseudoEncodingXCursor)) throw Exception("Client does not support local cursors"); diff --git a/common/rfb/SMsgWriter.h b/common/rfb/SMsgWriter.h index 07f7cf23..c46551e9 100644 --- a/common/rfb/SMsgWriter.h +++ b/common/rfb/SMsgWriter.h @@ -68,7 +68,7 @@ namespace rfb { const uint8_t* const* data); // writeFence() sends a new fence request or response to the client. - void writeFence(uint32_t flags, unsigned len, const char data[]); + void writeFence(uint32_t flags, unsigned len, const uint8_t data[]); // writeEndOfContinuousUpdates() indicates that we have left continuous // updates mode. @@ -135,10 +135,10 @@ namespace rfb { void writeSetDesktopNameRect(const char *name); void writeSetCursorRect(int width, int height, int hotspotX, int hotspotY, - const void* data, const void* mask); + const uint8_t* data, const uint8_t* mask); void writeSetXCursorRect(int width, int height, int hotspotX, int hotspotY, - const void* data, const void* mask); + const uint8_t* data, const uint8_t* mask); void writeSetCursorWithAlphaRect(int width, int height, int hotspotX, int hotspotY, const uint8_t* data); diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx index e65b6d3b..42f5009b 100644 --- a/common/rfb/SSecurityPlain.cxx +++ b/common/rfb/SSecurityPlain.cxx @@ -99,8 +99,8 @@ bool SSecurityPlain::processMsg() if (!is->hasData(ulen + plen)) return false; state = 2; - is->readBytes(username, ulen); - is->readBytes(password, plen); + is->readBytes((uint8_t*)username, ulen); + is->readBytes((uint8_t*)password, plen); password[plen] = 0; username[ulen] = 0; plen = 0; diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx index 042e4838..2a8dfa3e 100644 --- a/common/rfb/SSecurityRSAAES.cxx +++ b/common/rfb/SSecurityRSAAES.cxx @@ -539,12 +539,12 @@ bool SSecurityRSAAES::readCredentials() uint8_t lenUsername = rais->readU8(); if (!rais->hasDataOrRestore(lenUsername + 1)) return false; - rais->readBytes(username, lenUsername); + rais->readBytes((uint8_t*)username, lenUsername); username[lenUsername] = 0; uint8_t lenPassword = rais->readU8(); if (!rais->hasDataOrRestore(lenPassword)) return false; - rais->readBytes(password, lenPassword); + rais->readBytes((uint8_t*)password, lenPassword); password[lenPassword] = 0; rais->clearRestorePoint(); return true; diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx index acc9d5a5..54b620ea 100644 --- a/common/rfb/TightDecoder.cxx +++ b/common/rfb/TightDecoder.cxx @@ -192,10 +192,10 @@ bool TightDecoder::readRect(const Rect& r, rdr::InStream* is, } bool TightDecoder::doRectsConflict(const Rect& /*rectA*/, - const void* bufferA, + const uint8_t* bufferA, size_t buflenA, const Rect& /*rectB*/, - const void* bufferB, + const uint8_t* bufferB, size_t buflenB, const ServerParams& /*server*/) { @@ -219,7 +219,7 @@ bool TightDecoder::doRectsConflict(const Rect& /*rectA*/, return false; } -void TightDecoder::decodeRect(const Rect& r, const void* buffer, +void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb) { diff --git a/common/rfb/TightDecoder.h b/common/rfb/TightDecoder.h index 03b61daf..764f138e 100644 --- a/common/rfb/TightDecoder.h +++ b/common/rfb/TightDecoder.h @@ -34,13 +34,13 @@ namespace rfb { virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); virtual bool doRectsConflict(const Rect& rectA, - const void* bufferA, + const uint8_t* bufferA, size_t buflenA, const Rect& rectB, - const void* bufferB, + const uint8_t* bufferB, size_t buflenB, const ServerParams& server); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 5d047e6a..90311770 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -672,7 +672,7 @@ void VNCSConnectionST::setDesktopSize(int fb_width, int fb_height, writer()->writeDesktopSize(reasonClient, result); } -void VNCSConnectionST::fence(uint32_t flags, unsigned len, const char data[]) +void VNCSConnectionST::fence(uint32_t flags, unsigned len, const uint8_t data[]) { uint8_t type; @@ -685,7 +685,7 @@ void VNCSConnectionST::fence(uint32_t flags, unsigned len, const char data[]) delete [] fenceData; fenceData = NULL; if (len > 0) { - fenceData = new char[len]; + fenceData = new uint8_t[len]; memcpy(fenceData, data, len); } @@ -771,7 +771,7 @@ void VNCSConnectionST::supportsLocalCursor() void VNCSConnectionST::supportsFence() { - char type = 0; + uint8_t type = 0; writer()->writeFence(fenceFlagRequest, sizeof(type), &type); } @@ -825,7 +825,7 @@ bool VNCSConnectionST::isShiftPressed() void VNCSConnectionST::writeRTTPing() { - char type; + uint8_t type; if (!client.supportsFence()) return; diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h index 79f0b4fe..edc0391e 100644 --- a/common/rfb/VNCSConnectionST.h +++ b/common/rfb/VNCSConnectionST.h @@ -128,7 +128,7 @@ namespace rfb { virtual void framebufferUpdateRequest(const Rect& r, bool incremental); virtual void setDesktopSize(int fb_width, int fb_height, const ScreenSet& layout); - virtual void fence(uint32_t flags, unsigned len, const char data[]); + virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]); virtual void enableContinuousUpdates(bool enable, int x, int y, int w, int h); virtual void handleClipboardRequest(); @@ -174,7 +174,7 @@ namespace rfb { bool pendingSyncFence, syncFence; uint32_t fenceFlags; unsigned fenceDataLen; - char *fenceData; + uint8_t *fenceData; Congestion congestion; Timer congestionTimer; diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index 5f5ee34a..7bed8831 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -139,11 +139,11 @@ void VNCServerST::addSocket(network::Socket* sock, bool outgoing) rdr::OutStream& os = sock->outStream(); // Shortest possible way to tell a client it is not welcome - os.writeBytes("RFB 003.003\n", 12); + os.writeBytes((const uint8_t*)"RFB 003.003\n", 12); os.writeU32(0); const char* reason = "Too many security failures"; os.writeU32(strlen(reason)); - os.writeBytes(reason, strlen(reason)); + os.writeBytes((const uint8_t*)reason, strlen(reason)); os.flush(); } catch (rdr::Exception&) { } diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx index 6dad55f4..4b768afc 100644 --- a/common/rfb/ZRLEDecoder.cxx +++ b/common/rfb/ZRLEDecoder.cxx @@ -99,7 +99,7 @@ bool ZRLEDecoder::readRect(const Rect& /*r*/, rdr::InStream* is, return true; } -void ZRLEDecoder::decodeRect(const Rect& r, const void* buffer, +void ZRLEDecoder::decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb) { @@ -185,7 +185,7 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is, *ptr = readOpaque24B(zis); } } else { - zis->readBytes(buf, t.area() * sizeof(T)); + zis->readBytes((uint8_t*)buf, t.area() * sizeof(T)); } } else { diff --git a/common/rfb/ZRLEDecoder.h b/common/rfb/ZRLEDecoder.h index 3885124a..e72bf1b6 100644 --- a/common/rfb/ZRLEDecoder.h +++ b/common/rfb/ZRLEDecoder.h @@ -32,7 +32,7 @@ namespace rfb { virtual ~ZRLEDecoder(); virtual bool readRect(const Rect& r, rdr::InStream* is, const ServerParams& server, rdr::OutStream* os); - virtual void decodeRect(const Rect& r, const void* buffer, + virtual void decodeRect(const Rect& r, const uint8_t* buffer, size_t buflen, const ServerParams& server, ModifiablePixelBuffer* pb); diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 780214f2..a69eb014 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -434,7 +434,7 @@ void CConn::setCursorPos(const Point& pos) desktop->setCursorPos(pos); } -void CConn::fence(uint32_t flags, unsigned len, const char data[]) +void CConn::fence(uint32_t flags, unsigned len, const uint8_t data[]) { CMsgHandler::fence(flags, len, data); diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h index 0d8d7789..835699e5 100644 --- a/vncviewer/CConn.h +++ b/vncviewer/CConn.h @@ -65,7 +65,7 @@ public: const uint8_t* data); void setCursorPos(const rfb::Point& pos); - void fence(uint32_t flags, unsigned len, const char data[]); + void fence(uint32_t flags, unsigned len, const uint8_t data[]); void setLEDState(unsigned int state); |