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

Error parsing some seemingly valid binary plists (illegal integer size) #77

Closed
MarSoft opened this issue Apr 26, 2023 · 1 comment · Fixed by #78
Closed

Error parsing some seemingly valid binary plists (illegal integer size) #77

MarSoft opened this issue Apr 26, 2023 · 1 comment · Fixed by #78
Labels

Comments

@MarSoft
Copy link
Contributor

MarSoft commented Apr 26, 2023

First of all, I'm not sure if this error is in go-plist or in libplist.

The error is:
plist: error parsing binary property list: illegal integer size
Here is my minimal reproducing testing code:

package main

import "fmt"
import "os"
import "howett.net/plist"

func main() {
    dat, _ := os.ReadFile("t4.plist")
    var x [][]byte
    typ, err := plist.Unmarshal(dat, &x)
    fmt.Println(x, typ, err)
}

Output: [] 0 plist: error parsing binary property list: illegal integer size
Here is gzipped input file reproducing the problem: t4.plist.gz
It's just a plist consisting of an array element as its top-level structure, with just a single member which is a data object with length of 65523 bytes or more (its contents does not matter).
Here's the same plist in XML form, generated with plistutil from https://github.com/libimobiledevice/libplist version 2.2.0: t4.xml.gz

And here's a binary plist with the same data & structure but generated using go-plist:
t5.plist.gz

Even if the actual bug is in libplist, there are still some binary plists in the wild which were generated with it. And libplist handles both t4.plist and t5.plist without a question, but go-plist fails with t4.plist.

MarSoft added a commit to MarSoft/go-plist that referenced this issue Apr 26, 2023
Fixes DHowett#77.
Notice that this is only a partial fix which works for the value of 3 and for any value < 8, but won't help in other cases.
Supporting values < 16 should also be possible, but I didn't bother with it.
Also this doesn't touch `bplist_generator` and hence won't make use of non-standard values for generating plists (while those values could probably give a benefit of slightly reduced plist size).
@MarSoft MarSoft changed the title Error parsing some seemingly valid plists Error parsing some seemingly valid plists (illegal integer size) Apr 26, 2023
@MarSoft MarSoft changed the title Error parsing some seemingly valid plists (illegal integer size) Error parsing some seemingly valid binary plists (illegal integer size) Apr 26, 2023
@DHowett DHowett added the bug label Apr 26, 2023
@DHowett
Copy link
Owner

DHowett commented Apr 26, 2023

Totally a bug in go-plist! Thanks!

DHowett pushed a commit that referenced this issue May 1, 2023
This is only a partial fix which works for the value of 3 and for any
value < 8, but won't help in other cases. Supporting values < 16 should
also be possible, but I didn't bother with it. Also this doesn't touch
`bplist_generator` and hence won't make use of non-standard values for
generating plists (while those values could probably give a benefit of
slightly reduced plist size).

We confirmed that this is supported by the CoreFoundation bplist parser.

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

Successfully merging a pull request may close this issue.

2 participants