aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/TLSInStream.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-12-20 07:39:06 +0100
committerPierre Ossman <ossman@cendio.se>2019-12-20 07:39:06 +0100
commitd461f7fdb8b01f655260ea2f495ece700f3c9898 (patch)
tree5113b5a2844de4ce1469864d56c9786b3c4d63b0 /common/rdr/TLSInStream.cxx
parentc59f195d0ef2922bc163ac7cabfc94b9f1b25860 (diff)
parent05e28490873a861379c943bf616614b78b558b89 (diff)
downloadtigervnc-d461f7fdb8b01f655260ea2f495ece700f3c9898.tar.gz
tigervnc-d461f7fdb8b01f655260ea2f495ece700f3c9898.zip
Merge branch 'secfix' of https://github.com/CendioOssman/tigervnc
Diffstat (limited to 'common/rdr/TLSInStream.cxx')
-rw-r--r--common/rdr/TLSInStream.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index 8cd07b6c..cd81f224 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -43,7 +43,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
return -1;
}
- if (in->getend() - in->getptr() < (ptrdiff_t)size)
+ if ((size_t)(in->getend() - in->getptr()) < size)
size = in->getend() - in->getptr();
in->readBytes(data, size);
@@ -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");
@@ -92,20 +92,22 @@ int TLSInStream::overrun(int itemSize, int nItems, bool wait)
end -= ptr - start;
ptr = start;
- while (end < start + itemSize) {
- int n = readTLS((U8*) end, start + bufSize - end, wait);
+ while ((size_t)(end - start) < itemSize) {
+ size_t n = readTLS((U8*) end, start + bufSize - end, wait);
if (!wait && n == 0)
return 0;
end += n;
}
- if (itemSize * nItems > end - ptr)
- nItems = (end - ptr) / itemSize;
+ size_t nAvail;
+ nAvail = (end - ptr) / itemSize;
+ if (nAvail < nItems)
+ return nAvail;
return nItems;
}
-int TLSInStream::readTLS(U8* buf, int len, bool wait)
+size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait)
{
int n;