From 6a3f711878c33799c1c103d5d03910f960dd979a Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 10 Sep 2019 15:25:30 +0200 Subject: [PATCH] Add write protection to OffsetPixelBuffer No one should every try to write to this buffer. Enforce that by throwing an exception if any one tries to get a writeable pointer to the data. --- common/rfb/EncodeManager.cxx | 6 ++++++ common/rfb/EncodeManager.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx index fba3b33..983be73 100644 --- a/common/rfb/EncodeManager.cxx +++ b/common/rfb/EncodeManager.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -1494,6 +1495,11 @@ void EncodeManager::OffsetPixelBuffer::update(const PixelFormat& pf, stride = stride_; } +rdr::U8* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& r, int* stride) +{ + throw rfb::Exception("Invalid write attempt to OffsetPixelBuffer"); +} + // Preprocessor generated, optimised methods #define BPP 8 diff --git a/common/rfb/EncodeManager.h b/common/rfb/EncodeManager.h index 97dff6e..8f86292 100644 --- a/common/rfb/EncodeManager.h +++ b/common/rfb/EncodeManager.h @@ -187,6 +187,9 @@ namespace rfb { void update(const PixelFormat& pf, int width, int height, const rdr::U8* data_, int stride); + + private: + virtual rdr::U8* getBufferRW(const Rect& r, int* stride); }; }; }