diff options
Diffstat (limited to 'common/rdr/RandomStream.cxx')
-rw-r--r-- | common/rdr/RandomStream.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx index ec367212..c9be704c 100644 --- a/common/rdr/RandomStream.cxx +++ b/common/rdr/RandomStream.cxx @@ -83,17 +83,17 @@ RandomStream::~RandomStream() { #endif } -bool RandomStream::fillBuffer(size_t maxSize) { +bool RandomStream::fillBuffer() { #ifdef RFB_HAVE_WINCRYPT if (provider) { - if (!CryptGenRandom(provider, maxSize, (U8*)end)) + if (!CryptGenRandom(provider, availSpace(), (U8*)end)) throw rdr::SystemException("unable to CryptGenRandom", GetLastError()); - end += maxSize; + end += availSpace(); } else { #else #ifndef WIN32 if (fp) { - size_t n = fread((U8*)end, 1, maxSize, fp); + size_t n = fread((U8*)end, 1, availSpace(), fp); if (n <= 0) throw rdr::SystemException("reading /dev/urandom or /dev/random failed", errno); @@ -103,7 +103,7 @@ bool RandomStream::fillBuffer(size_t maxSize) { { #endif #endif - for (size_t i=0; i<maxSize; i++) + for (size_t i=availSpace(); i>0; i--) *(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0)); } |