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

BMP file truncated following parse/unparse #2

Open
lblatchford opened this issue Dec 3, 2020 · 1 comment
Open

BMP file truncated following parse/unparse #2

lblatchford opened this issue Dec 3, 2020 · 1 comment

Comments

@lblatchford
Copy link

The last 106 bytes of the BMP in the attached zip are removed after the file is parsed and unparsed using Daffodil 2.7.0 (Java API).

token.zip

@stevedlawrence
Copy link
Member

I think there are sort of two issues here:

  1. The File_Size field in the BMP_File_Header (bytes 2-6) do not appear to be correct. This field has a value of 60514, but the file size is actually 60618 bytes, so it's short by 104 bytes. Either this is intentional and the File_Size field isn't supposed to describe the size of the entire file in some cases, or this field is corrupt--it's not obvious to me based on a quick reading of the spec. If it's the latter and this field is corrupt, I assume most bitmap parsers just ignore this field and rely entirely on fields in the DIB_Header to parse a full bitmap file, so this field being wrong doesn't really matter in most cases. Which leads to issue 2:
  2. This schema is not really complete. All it really does is parse the BMP_FIle_Header and the DIB_Header and treats the rest of the file as a blob. In order to calculate the length of the rest of the file to turn it into a blob, we use the aformentioned File_Size field and subtract the lengths of the BMP_File_Header and DIB_Header. But this relies on a correct File_Size field which does not appear to be the case.

The right fix is probably to update the schema so that we actually describe the pixel data, or at least use different fields to figure out the length the pixel data if we can't always rely on the accuracy of the File_Size field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants