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

4-byte long real numbers parsing #38

Open
AnatolyRugalev opened this issue Feb 5, 2023 · 0 comments · May be fixed by #39
Open

4-byte long real numbers parsing #38

AnatolyRugalev opened this issue Feb 5, 2023 · 0 comments · May be fixed by #39

Comments

@AnatolyRugalev
Copy link

AnatolyRugalev commented Feb 5, 2023

I have an issue with plist files that macOS keeps in Preferences folder, and after some debugging I found that decoder does not respect possibility of the floating point number to be 4 bytes long.

What I get: unexpected EOF returned by parseReal, specifically from this line: https://github.com/groob/plist/blob/63fa881b19a57babfe576f2750f5dc3b29ebb69f/binary_parser.go#L257

The length of the byte slice there is 4 bytes, but binary.Read expects 8 bytes for float64 type.

This can probably be fixed with byte length check and with float32 type in case the length is 4. Then, it can be safely converted to float64 for internal use.

I noticed that converting problematic files to xml and back to binary solves the issue: plist encodes new binary files with float64 bytes, however, this is not a suitable workaround for me.

@AnatolyRugalev AnatolyRugalev changed the title 4-byte long float parsing 4-byte long real numbers parsing Feb 5, 2023
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

Successfully merging a pull request may close this issue.

1 participant