diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-05-23 22:44:57 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-05-23 22:44:57 +0700 |
commit | 98b3ce6512812cd1d91c60ca0e69d69c32838d8e (patch) | |
tree | 8af69c097b389fe494e97401f7808590314a5b6b /crypto/src/tls/ByteQueueInputStream.cs | |
parent | Add ValidateBufferArguments (diff) | |
download | BouncyCastle.NET-ed25519-98b3ce6512812cd1d91c60ca0e69d69c32838d8e.tar.xz |
Work on Stream classes
- consistent naming, ordering - CanRead/Seek/Write fixes - argument validation - some cases of blocking zero-byte Read calls
Diffstat (limited to 'crypto/src/tls/ByteQueueInputStream.cs')
-rw-r--r-- | crypto/src/tls/ByteQueueInputStream.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/src/tls/ByteQueueInputStream.cs b/crypto/src/tls/ByteQueueInputStream.cs index b59b5d1e7..0b15071ad 100644 --- a/crypto/src/tls/ByteQueueInputStream.cs +++ b/crypto/src/tls/ByteQueueInputStream.cs @@ -31,6 +31,15 @@ namespace Org.BouncyCastle.Tls return bytesToRead; } + public override int Read(byte[] buffer, int offset, int count) + { + Streams.ValidateBufferArguments(buffer, offset, count); + + int bytesToRead = System.Math.Min(m_buffer.Available, count); + m_buffer.RemoveData(buffer, offset, bytesToRead, 0); + return bytesToRead; + } + public override int ReadByte() { if (m_buffer.Available == 0) @@ -39,13 +48,6 @@ namespace Org.BouncyCastle.Tls return m_buffer.RemoveData(1, 0)[0]; } - public override int Read(byte[] buf, int off, int len) - { - int bytesToRead = System.Math.Min(m_buffer.Available, len); - m_buffer.RemoveData(buf, off, bytesToRead, 0); - return bytesToRead; - } - public long Skip(long n) { int bytesToRemove = System.Math.Min((int)n, m_buffer.Available); |