Skip to content

Commit

Permalink
CircularBuffer: Check length before decoding with System.Text
Browse files Browse the repository at this point in the history
Trying to decode a zero length source buffer on Mono may result in an ArgumentException (observed with ISO-8859-15, but not with UTF8/ASCII).

The exception raised also has no parameter set, thus a check needs to be done to ensure that the ParamName is not null, else this situation will result in a double fault with a NullReferenceException also.

Issue: DOTNET-194
  • Loading branch information
jcurl committed Jul 5, 2020
1 parent 4950e54 commit dd169fd
Show file tree
Hide file tree
Showing 9 changed files with 743 additions and 372 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# List of Changes with Releases

## Version 2.2.2 (libnserial 1.1.4)

Bugfixes

* DOTNET-194: Prevent exceptions when converting bytes to chars when using
ISO-8859-15.

## Version 2.2.1 (libnserial 1.1.4)

Bugfixes
Expand Down
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ example.
These notes are for version 2.x, which is a new design based on version 1.x that
enhances portability and fixes bugs. See the end of these notes for differences.

* 1.0 Why another Serial Port implementation
* 2.0 Goals
* 2.1 Issues with MS Serial Port
* 3.0 System Requirements
* 3.1 Tested
* 3.2 Compatibility
* 3.2.1 Mono Framework (Linux Only)
* 3.2.2 Microsoft Compact Framework (not supported)
* 3.2.3 Untested, but should work
* 4.0 Installation
* 4.1 Windows
* 4.2 Linux
* 5.0 Extra Features
* 5.1 Reading and Writing - Buffering
* 6.0 Known Issues
* 6.1 Windows
* 6.1.1 Driver Specific Issues on Windows
* 6.1.1.1 Flow Control
* 6.2 Linux
* 6.2.1 Mono on non-Windows Platforms
* 6.2.2 Driver Specific Issues on Linux
* 6.2.2.1 Parity Errors
* 6.2.2.2 Garbage Data on Open
* 6.2.2.3 Monitoring Pins and Timing Resolution
* 6.2.2.4 Close Times with Flow Control

## 1.0 Why another Serial Port implementation

Microsoft and Mono already provides a reasonable implementation for accessing
Expand Down Expand Up @@ -87,7 +113,10 @@ See later in these notes for known issues and changes.

### 3.2 Compatibility

#### 3.2.1 Mono Framework
#### 3.2.1 Mono Framework (Linux Only)

Only Mono on Linux is supported. Embedded platforms are not supported. You are
welcome to make a patch with appropriate test cases.

You should use the latest version of Mono. Version 3.2.8 has significant bugs
and will not work (Ubuntu 14.04 ships with this). Use the latest version of Mono
Expand All @@ -97,7 +126,7 @@ For instructions on how to install the latest Mono for your system, refer to
[Install Mono On
Linux](http://www.mono-project.com/docs/getting-started/install/linux/).

#### 3.2.2 Microsoft Compact Framework
#### 3.2.2 Microsoft Compact Framework (not supported)

SerialPortStream is not designed for the Compact Framework.

Expand Down
829 changes: 503 additions & 326 deletions code/Datastructures/CircularBuffer.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions code/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.1.0")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: AssemblyVersion("2.2.2.0")]
[assembly: AssemblyFileVersion("2.2.2.0")]
2 changes: 1 addition & 1 deletion code/SerialPortStream-net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ReleaseVersion>2.2.1.0</ReleaseVersion>
<ReleaseVersion>2.2.2.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion code/SerialPortStream-net45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ReleaseVersion>2.2.1.0</ReleaseVersion>
<ReleaseVersion>2.2.2.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion code/SerialPortStream-netstandard15.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>An independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability.</Description>
<AssemblyTitle>SerialPortStream</AssemblyTitle>
<VersionPrefix>2.2.1.0</VersionPrefix>
<VersionPrefix>2.2.2.0</VersionPrefix>
<TargetFramework>netstandard1.5</TargetFramework>
<DefineConstants>$(DefineConstants);NETSTANDARD15</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion code/SerialPortStream.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>SerialPortStream</id>
<version>2.2.1.1</version>
<version>2.2.2</version>
<title>SerialPortStream</title>
<authors>Jason Curl</authors>
<owners>Jason Curl</owners>
Expand Down
Loading

0 comments on commit dd169fd

Please sign in to comment.