diff options
author | Pierre Ossman <ossman@cendio.se> | 2019-09-23 11:00:17 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2019-11-15 11:55:05 +0100 |
commit | 0943c006c7d900dfc0281639e992791d6c567438 (patch) | |
tree | 9393960c3d86df32f6186a6feeb4fecfec376699 /common/rdr/TLSOutStream.cxx | |
parent | 4ff58f0acaeb566b79ae12cf013b376eaaaab834 (diff) | |
download | tigervnc-0943c006c7d900dfc0281639e992791d6c567438.tar.gz tigervnc-0943c006c7d900dfc0281639e992791d6c567438.zip |
Use size_t for lengths in stream objects
Provides safety against them accidentally becoming negative because
of bugs in the calculations.
Also does the same to CharArray and friends as they were strongly
connection to the stream objects.
Diffstat (limited to 'common/rdr/TLSOutStream.cxx')
-rw-r--r-- | common/rdr/TLSOutStream.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx index 44d2d9f3..30c456fe 100644 --- a/common/rdr/TLSOutStream.cxx +++ b/common/rdr/TLSOutStream.cxx @@ -75,7 +75,7 @@ TLSOutStream::~TLSOutStream() delete [] start; } -int TLSOutStream::length() +size_t TLSOutStream::length() { return offset + ptr - start; } @@ -84,7 +84,7 @@ void TLSOutStream::flush() { U8* sentUpTo = start; while (sentUpTo < ptr) { - int n = writeTLS(sentUpTo, ptr - sentUpTo); + size_t n = writeTLS(sentUpTo, ptr - sentUpTo); sentUpTo += n; offset += n; } @@ -93,20 +93,20 @@ void TLSOutStream::flush() out->flush(); } -int TLSOutStream::overrun(int itemSize, int nItems) +size_t TLSOutStream::overrun(size_t itemSize, size_t nItems) { if (itemSize > bufSize) throw Exception("TLSOutStream overrun: max itemSize exceeded"); flush(); - if (itemSize * nItems > end - ptr) + if (itemSize * nItems > (size_t)(end - ptr)) nItems = (end - ptr) / itemSize; return nItems; } -int TLSOutStream::writeTLS(const U8* data, int length) +size_t TLSOutStream::writeTLS(const U8* data, size_t length) { int n; |