Skip to content

Commit

Permalink
Merge pull request #20 from ekonbenefits/bad_data_infinite_loop
Browse files Browse the repository at this point in the history
Bad data infinite loop
  • Loading branch information
jbtule authored May 30, 2017
2 parents 9b707ca + 2a00246 commit 8bc01ab
Show file tree
Hide file tree
Showing 43 changed files with 528 additions and 17 deletions.
26 changes: 26 additions & 0 deletions DotNetDBF.Test/DotNetDBF.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,26 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Issue19Test.cs" />
<Compile Include="Test.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="dbfs\cp1251.dbf" />
<EmbeddedResource Include="dbfs\dbase_03.dbf" />
<EmbeddedResource Include="dbfs\dbase_30.dbf" />
<EmbeddedResource Include="dbfs\dbase_30.fpt" />
<EmbeddedResource Include="dbfs\dbase_31.dbf" />
<EmbeddedResource Include="dbfs\dbase_83.dbf" />
<EmbeddedResource Include="dbfs\dbase_83.dbt" />
<EmbeddedResource Include="dbfs\dbase_83_missing_memo.dbf" />
<EmbeddedResource Include="dbfs\dbase_83_missing_memo_record_0.yml" />
<EmbeddedResource Include="dbfs\dbase_83_record_0.yml" />
<EmbeddedResource Include="dbfs\dbase_83_record_9.yml" />
<EmbeddedResource Include="dbfs\dbase_8b.dbf" />
<EmbeddedResource Include="dbfs\dbase_8b.dbt" />
<EmbeddedResource Include="dbfs\dbase_f5.dbf" />
<EmbeddedResource Include="dbfs\dbase_f5.fpt" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -59,5 +75,15 @@
<Name>DotNetDBF</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="dbfs\cp1251_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_03_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_30_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_31_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_83_schema.txt" />
<EmbeddedResource Include="dbfs\dbase_83_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_8b_summary.txt" />
<EmbeddedResource Include="dbfs\dbase_f5_summary.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
31 changes: 31 additions & 0 deletions DotNetDBF.Test/Issue19Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace DotNetDBF.Test
{

[TestFixture]
public class Issue19Test
{
private Stream DbfsData(string filename) => typeof(Issue19Test).Assembly
.GetManifestResourceStream($"{nameof(DotNetDBF)}.{nameof(Test)}.dbfs.{filename}");

[Test]
public void ReadTest()
{
using (var dbfstream = DbfsData("dbase_8b.dbf"))
using (var memoStream = DbfsData("dbase_8b.dbt"))
using (DBFReader dbfr = new DBFReader(dbfstream) { DataMemo = memoStream})
{
object[] record = dbfr.NextRecord();
//This line would hang issue #19 https://github.com/ekonbenefits/dotnetdbf/issues/19
Assert.Throws<DBTException>(() => record[5].ToString());
}
}
}
}
22 changes: 22 additions & 0 deletions DotNetDBF.Test/dbfs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Most of the DBFs here are from the spec directory of the dbf ruby gem

Copyright (c) 2006-2017 Keith Morrison <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added DotNetDBF.Test/dbfs/cp1251.dbf
Binary file not shown.
11 changes: 11 additions & 0 deletions DotNetDBF.Test/dbfs/cp1251_summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

Database: cp1251.dbf
Type: (30) Visual FoxPro
Memo File: false
Records: 4

Fields:
Name Type Length Decimal
------------------------------------------------------------------------------
RN N 4 0
NAME C 100 0
Binary file added DotNetDBF.Test/dbfs/dbase_03.dbf
Binary file not shown.
40 changes: 40 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_03_summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Database: dbase_03.dbf
Type: (03) dBase III without memo file
Memo File: false
Records: 14

Fields:
Name Type Length Decimal
------------------------------------------------------------------------------
Point_ID C 12 0
Type C 20 0
Shape C 20 0
Circular_D C 20 0
Non_circul C 60 0
Flow_prese C 20 0
Condition C 20 0
Comments C 60 0
Date_Visit D 8 0
Time C 10 0
Max_PDOP N 5 1
Max_HDOP N 5 1
Corr_Type C 36 0
Rcvr_Type C 36 0
GPS_Date D 8 0
GPS_Time C 10 0
Update_Sta C 36 0
Feat_Name C 20 0
Datafile C 20 0
Unfilt_Pos N 10 0
Filt_Pos N 10 0
Data_Dicti C 20 0
GPS_Week N 6 0
GPS_Second N 12 3
GPS_Height N 16 3
Vert_Prec N 16 1
Horz_Prec N 16 1
Std_Dev N 16 6
Northing N 16 3
Easting N 16 3
Point_ID N 9 0
Binary file added DotNetDBF.Test/dbfs/dbase_30.dbf
Binary file not shown.
Binary file added DotNetDBF.Test/dbfs/dbase_30.fpt
Binary file not shown.
154 changes: 154 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_30_summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

Database: dbase_30.dbf
Type: (30) Visual FoxPro
Memo File: true
Records: 34

Fields:
Name Type Length Decimal
------------------------------------------------------------------------------
ACCESSNO C 15 0
ACQVALUE N 12 2
APPNOTES M 4 0
APPRAISOR C 75 0
CABINET C 25 0
CAPTION C 30 0
CAT C 1 0
CATBY C 25 0
CATDATE D 8 0
CATTYPE C 15 0
CLASSES M 4 0
COLLECTION C 75 0
CONDDATE D 8 0
CONDEXAM C 25 0
CONDITION C 35 0
CONDNOTES M 4 0
CONTAINER C 40 0
COPYRIGHT M 4 0
CREATOR C 80 0
CREDIT M 4 0
CURVALMAX N 12 2
CURVALUE N 12 2
DATASET C 15 0
DATE C 50 0
DESCRIP M 4 0
DIMNOTES M 4 0
DISPVALUE C 10 0
DRAWER C 20 0
EARLYDATE N 4 0
EVENT C 80 0
EXHIBITID C 36 0
EXHIBITNO N 7 0
EXHLABEL1 M 4 0
EXHLABEL2 M 4 0
EXHLABEL3 M 4 0
EXHLABEL4 M 4 0
EXHSTART D 8 0
FILMSIZE C 35 0
FLAGDATE T 8 0
FLAGNOTES M 4 0
FLAGREASON C 20 0
FRAME C 75 0
FRAMENO C 25 0
GPARENT C 45 0
HOMELOC C 60 0
IMAGEFILE C 60 0
IMAGENO N 3 0
INSCOMP C 30 0
INSDATE D 8 0
INSPHONE C 25 0
INSPREMIUM C 20 0
INSREP C 30 0
INSVALUE N 10 2
INVNBY C 25 0
INVNDATE D 8 0
LATEDATE N 4 0
LEGAL M 4 0
LOANCOND M 4 0
LOANDATE D 8 0
LOANDUE D 8 0
LOANID C 36 0
LOANINNO C 15 0
MAINTCYCLE C 10 0
MAINTDATE D 8 0
MAINTNOTE M 4 0
MEDIUM C 75 0
NEGLOC C 60 0
NEGNO C 25 0
NOTES M 4 0
OBJECTID C 25 0
OBJNAME C 40 0
OLDNO C 25 0
ORIGCOPY C 15 0
OTHERNO C 25 0
OUTDATE D 8 0
PARENT C 40 0
PEOPLE M 4 0
PLACE C 100 0
POLICYNO C 20 0
PRINTSIZE C 35 0
PROCESS C 75 0
PROVENANCE M 4 0
PUBNOTES M 4 0
RECAS C 20 0
RECDATE C 10 0
RECFROM C 120 0
RELATION C 36 0
RELNOTES M 4 0
ROOM C 25 0
SGFLAG C 1 0
SHELF C 20 0
SITE C 40 0
SITENO C 12 0
SLIDENO C 25 0
STATUS C 20 0
STATUSBY C 25 0
STATUSDATE D 8 0
STERMS M 4 0
STUDIO C 60 0
SUBJECTS M 4 0
TCABINET C 25 0
TCONTAINER C 40 0
TDRAWER C 20 0
TEMPAUTHOR C 25 0
TEMPBY C 25 0
TEMPDATE D 8 0
TEMPLOC C 60 0
TEMPNOTES M 4 0
TEMPREASON C 50 0
TEMPUNTIL C 10 0
TITLE M 4 0
TITLESORT C 100 0
TROOM C 25 0
TSHELF C 20 0
TWALL C 20 0
UDF1 C 75 0
UDF10 C 75 0
UDF11 C 20 0
UDF12 C 20 0
UDF13 N 12 0
UDF14 N 12 2
UDF15 N 12 2
UDF16 N 12 3
UDF17 N 12 3
UDF18 D 8 0
UDF19 D 8 0
UDF20 D 8 0
UDF21 M 4 0
UDF22 M 4 0
UDF2 C 75 0
UDF3 C 75 0
UDF4 C 75 0
UDF5 C 75 0
UDF6 C 75 0
UDF7 C 75 0
UDF8 C 75 0
UDF9 C 75 0
UPDATED T 8 0
UPDATEDBY C 25 0
VALUEDATE D 8 0
WALL C 20 0
WEBINCLUDE L 1 0
ZSORTER C 69 0
ZSORTERX C 44 0
PPID C 36 0
Binary file added DotNetDBF.Test/dbfs/dbase_31.dbf
Binary file not shown.
20 changes: 20 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_31_summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Database: dbase_31.dbf
Type: (31) Visual FoxPro with AutoIncrement field
Memo File: false
Records: 77

Fields:
Name Type Length Decimal
------------------------------------------------------------------------------
PRODUCTID I 4 0
PRODUCTNAM C 40 0
SUPPLIERID I 4 0
CATEGORYID I 4 0
QUANTITYPE C 20 0
UNITPRICE Y 8 4
UNITSINSTO I 4 0
UNITSONORD I 4 0
REORDERLEV I 4 0
DISCONTINU L 1 0
_NullFlags 0 1 0
Binary file added DotNetDBF.Test/dbfs/dbase_83.dbf
Binary file not shown.
Binary file added DotNetDBF.Test/dbfs/dbase_83.dbt
Binary file not shown.
Binary file added DotNetDBF.Test/dbfs/dbase_83_missing_memo.dbf
Binary file not shown.
16 changes: 16 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_83_missing_memo_record_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- 87
- 2
- 0
- 0
- 87
- '1'
- Assorted Petits Fours
- graphics/00000001/t_1.jpg
- graphics/00000001/1.jpg
- 0.0
- 0.0
-
- 5.51
- true
- true
16 changes: 16 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_83_record_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- 87
- 2
- 0
- 0
- 87
- '1'
- Assorted Petits Fours
- graphics/00000001/t_1.jpg
- graphics/00000001/1.jpg
- 0.0
- 0.0
- "Our Original assortment...a little taste of heaven for everyone. Let us\r\nselect a special assortment of our chocolate and pastel favorites for you.\r\nEach petit four is its own special hand decorated creation. Multi-layers of\r\nmoist cake with combinations of specialty fillings create memorable cake\r\nconfections. Varietes include; Luscious Lemon, Strawberry Hearts, White\r\nChocolate, Mocha Bean, Roasted Almond, Triple Chocolate, Chocolate Hazelnut,\r\nGrand Orange, Plum Squares, Milk chocolate squares, and Raspberry Blanc."
- 5.51
- true
- true
23 changes: 23 additions & 0 deletions DotNetDBF.Test/dbfs/dbase_83_record_9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- 34
- 1
- 0
- 0
- 34
- AB01
- Apricot Brandy Fruitcake
- graphics/00000001/t_AB01.jpg
- graphics/00000001/AB01.jpg
- 37.95
- 37.95
- "Once tasted you will understand why we won The\r\nBoston Herald's Fruitcake Taste-off.
Judges liked its generous size,\r\nluscious appearance, moist texture and fruit
to cake ratio ... commented one\r\njudge \"It's a lip Smacker!\" Our signature fruitcake
is baked with carefully\r\nselected ingredients that will be savored until the last
moist crumb is\r\ndevoured each golden slice is brimming with Australian glaced
apricots,\r\ntoasted pecans, candied orange peel, and currants, folded gently into
a\r\nbrandy butter batter and slowly baked to perfection and then generously\r\nimbibed
with \"Holiday Spirits\". Presented in a gift tin. (3lbs. 4oz)"
- 0.0
- false
- true
Loading

0 comments on commit 8bc01ab

Please sign in to comment.