aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/TLSInStream.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-09-23 11:00:17 +0200
committerPierre Ossman <ossman@cendio.se>2019-11-15 11:55:05 +0100
commit0943c006c7d900dfc0281639e992791d6c567438 (patch)
tree9393960c3d86df32f6186a6feeb4fecfec376699 /common/rdr/TLSInStream.cxx
parent4ff58f0acaeb566b79ae12cf013b376eaaaab834 (diff)
downloadtigervnc-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/TLSInStream.cxx')
-rw-r--r--common/rdr/TLSInStream.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index 77b16729..d0f94263 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -75,12 +75,12 @@ TLSInStream::~TLSInStream()
delete[] start;
}
-int TLSInStream::pos()
+size_t TLSInStream::pos()
{
return offset + ptr - start;
}
-int TLSInStream::overrun(int itemSize, int nItems, bool wait)
+size_t TLSInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
if (itemSize > bufSize)
throw Exception("TLSInStream overrun: max itemSize exceeded");
@@ -93,19 +93,19 @@ int TLSInStream::overrun(int itemSize, int nItems, bool wait)
ptr = start;
while (end < start + itemSize) {
- int n = readTLS((U8*) end, start + bufSize - end, wait);
+ size_t n = readTLS((U8*) end, start + bufSize - end, wait);
if (!wait && n == 0)
return 0;
end += n;
}
- if (itemSize * nItems > end - ptr)
+ if (itemSize * nItems > (size_t)(end - ptr))
nItems = (end - ptr) / itemSize;
return nItems;
}
-int TLSInStream::readTLS(U8* buf, int len, bool wait)
+size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait)
{
int n;