]> source.dussan.org Git - tigervnc.git/commitdiff
Add write protection to OffsetPixelBuffer
authorPierre Ossman <ossman@cendio.se>
Tue, 10 Sep 2019 13:25:30 +0000 (15:25 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 15 Nov 2019 10:20:26 +0000 (11:20 +0100)
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
common/rfb/EncodeManager.h

index 54f7102b18d756fb6af3d7b542a9ff4c46a20292..92ac5676d6458573acd42114c59944c53e1098f1 100644 (file)
@@ -28,6 +28,7 @@
 #include <rfb/SMsgWriter.h>
 #include <rfb/UpdateTracker.h>
 #include <rfb/LogWriter.h>
+#include <rfb/Exception.h>
 
 #include <rfb/RawEncoder.h>
 #include <rfb/RREEncoder.h>
@@ -1053,6 +1054,11 @@ void EncodeManager::OffsetPixelBuffer::update(const PixelFormat& pf,
   setBuffer(width, height, (rdr::U8*)data_, 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
index bdae9063b7f546355429915f3cd0f4b787163dd4..f8201c34623b4c7525de441c0c22bb24a4399ccd 100644 (file)
@@ -148,6 +148,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);
     };
 
     OffsetPixelBuffer offsetPixelBuffer;