diff options
author | Pierre Ossman <ossman@cendio.se> | 2019-09-10 15:18:30 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2019-11-15 10:53:26 +0100 |
commit | 53f913a76196c7357d4858bfbf2c33caa9181bae (patch) | |
tree | fed2268563ae4b752af780ce8f99f63a3b2af6ae /common/rfb/PixelBuffer.h | |
parent | d61a767d6842b530ffb532ddd5a3d233119aad40 (diff) | |
download | tigervnc-53f913a76196c7357d4858bfbf2c33caa9181bae.tar.gz tigervnc-53f913a76196c7357d4858bfbf2c33caa9181bae.zip |
Encapsulate PixelBuffer internal details
Don't allow subclasses to just override dimensions or buffer details
directly and instead force them to go via methods. This allows us
to do sanity checks on the new values and catch bugs and attacks.
Diffstat (limited to 'common/rfb/PixelBuffer.h')
-rw-r--r-- | common/rfb/PixelBuffer.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h index d89793f5..3e4018f9 100644 --- a/common/rfb/PixelBuffer.h +++ b/common/rfb/PixelBuffer.h @@ -90,7 +90,12 @@ namespace rfb { protected: PixelBuffer(); + virtual void setSize(int width, int height); + + protected: PixelFormat format; + + private: int width_, height_; }; @@ -154,7 +159,12 @@ namespace rfb { protected: FullFramePixelBuffer(); + virtual void setBuffer(int width, int height, rdr::U8* data, int stride); + private: + virtual void setSize(int w, int h); + + private: rdr::U8* data; int stride; }; @@ -172,12 +182,9 @@ namespace rfb { virtual void setPF(const PixelFormat &pf); virtual void setSize(int w, int h); - // Return the total number of bytes of pixel data in the buffer - int dataLen() const { return width_ * height_ * (format.bpp/8); } - - protected: + private: + rdr::U8* data_; // Mirrors FullFramePixelBuffer::data unsigned long datasize; - void checkDataSize(); }; }; |