Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes there is no Field Descriptor terminator 0x0D. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion DotNetDBF/DBFHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ internal void Read(BinaryReader dataInput)
while (field != null)
{
v_fields.Add(field);
field = DBFField.CreateField(dataInput);

if ((HeaderLength - dataInput.BaseStream.Position) < 32)
{
break;
}

field = DBFField.CreateField(dataInput);
}

FieldArray = v_fields.ToArray();
Expand Down
6 changes: 2 additions & 4 deletions DotNetDBF/DBFReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ public DBFReader(string anIn)
_header.Read(_dataInputStream);

/* it might be required to leap to the start of records at times */
var t_dataStartIndex = _header.HeaderLength
- (32 + (32 * _header.FieldArray.Length))
- 1;
var t_dataStartIndex = _header.HeaderLength - _dataInputStream.BaseStream.Position;
if (t_dataStartIndex > 0)
{
_dataInputStream.ReadBytes((t_dataStartIndex));
_dataInputStream.ReadBytes((int)(t_dataStartIndex));
}
}
catch (IOException ex)
Expand Down