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/asn1/ConstructedOctetStream.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/asn1/ConstructedOctetStream.cs')
-rw-r--r-- | crypto/src/asn1/ConstructedOctetStream.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/src/asn1/ConstructedOctetStream.cs b/crypto/src/asn1/ConstructedOctetStream.cs index 5541939b6..12aa14e74 100644 --- a/crypto/src/asn1/ConstructedOctetStream.cs +++ b/crypto/src/asn1/ConstructedOctetStream.cs @@ -18,9 +18,11 @@ namespace Org.BouncyCastle.Asn1 m_parser = parser; } - public override int Read(byte[] buf, int off, int len) + public override int Read(byte[] buffer, int offset, int count) { - if (len < 1) + Streams.ValidateBufferArguments(buffer, offset, count); + + if (count < 1) return 0; if (m_currentStream == null) @@ -40,13 +42,13 @@ namespace Org.BouncyCastle.Asn1 for (;;) { - int numRead = m_currentStream.Read(buf, off + totalRead, len - totalRead); + int numRead = m_currentStream.Read(buffer, offset + totalRead, count - totalRead); if (numRead > 0) { totalRead += numRead; - if (totalRead == len) + if (totalRead == count) return totalRead; } else |