Skip to content

Avoid throwing exception for unknown field type #364

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 5 additions & 8 deletions src/TaglibSharp/IFD/IFDReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,12 @@ uint ReadIFD (long baseOffset, uint offset, uint maxOffset)

IFDEntry entry;

try
{
entry = CreateIFDEntry(entry_tag, type, value_count, baseOffset, offset_data, maxOffset);
}
catch (OverflowException)
{
try {
entry = CreateIFDEntry (entry_tag, type, value_count, baseOffset, offset_data, maxOffset);
} catch (OverflowException) {
// This exception occurs when the image does not have data in the expected format at the
// requested location. This has been observed in images taken with an Olympus camera.
file.MarkAsCorrupt("Invalid IFD entry");
file.MarkAsCorrupt ("Invalid IFD entry");
continue;
}

Expand Down Expand Up @@ -549,7 +546,7 @@ IFDEntry CreateIFDEntry (ushort tag, ushort type, uint count, long baseOffset, B
file.MarkAsCorrupt ("Invalid item type");
return null;
}

return null;
// TODO: We should ignore unreadable values, erroring for now until we have sufficient coverage.
throw new NotImplementedException ($"Unknown type/count {type}/{count} ({offset})");
}
Expand Down