]> 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, 20 Dec 2019 06:29:00 +0000 (07:29 +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.

(cherry picked from commit 9f615301aba1cc54a749950bf9462c5a85217bc4)

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;