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

I've found real-world instances of 128bit ints in plists #10

Open
DannyThomas opened this issue May 23, 2021 · 5 comments
Open

I've found real-world instances of 128bit ints in plists #10

DannyThomas opened this issue May 23, 2021 · 5 comments
Assignees
Labels
Status: needs help needs outside expertise or capacity Status: stalled something is blocking progress

Comments

@DannyThomas
Copy link

DannyThomas commented May 23, 2021

This was running under macOS 11.4beta upgraded from 10.13
so was originally confused by sandboxing.

I'm writing a utility to report differences in plist files.
This means I'm recursively traversing all files under:
/Library/Preferences
~/Library/Preferences
using Mac::PropertyList::parse_plist_file. I'm using v1.502,
albeit by not properly installing but by unpacking and copying
the 'lib' directory, which is normally OK for Pure-Perl modules.

After modifying my script to ignore non-plist files and
allowing Terminal full-access to the disk, I was getting
croak "Integer > 8 bytes = $length"

After applying the attached diff, I got the following output
with no croaks(). The file-path is printed by my script before
it calls parse_plist_file
/Users/dthomas/Library/Preferences/.GlobalPreferences.plist
128bit int has top 64bits of zero
00000000 00000000 00000000 000007D0
so truncate it to a 64bit int
/Users/dthomas/Library/Preferences/com.apple.finder.plist
128bit int has top 64bits of zero
00000000 00000000 00000000 00000001
so truncate it to a 64bit int
/Users/dthomas/Library/Preferences/com.apple.ncprefs.plist
128bit int has top 64bits of zero
00000000 00000000 80000000 00000000
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000007
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000000
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000007
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000000
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000000
so truncate it to a 64bit int
128bit int has top 64bits of zero
00000000 00000000 80000000 00000000
so truncate it to a 64bit int

Originally I thought I might have to provide some support for
128bit integers. But since all the cases I've seen can be
truncated, there's no need.

NB The irony is the length bits of ints/reals in
https://github.com/opensource-apple/CF/blob/master/CFBinaryPList.c
are marked '0nnn', whereas 'nnnn' was the case in the older
https://opensource.apple.com/source/CF/CF-550/CFBinaryPList.c

I thought I could create a test file with one attribute having a
128bit integer value
$ defaults write t1 128bit-integer -int 1208925819614629174706176
which is 2^80
$ plutil -convert xml1 -o - ~/Library/Preferences/t1.plist

128bit-integer 9223372036854775807 My script does not report the attribute valeu being 128bits, so it looks like defaults silently truncates integers to < 2^64. [ReadBinary.pm.diff.txt](https://github.com/briandfoy/mac-propertylist/files/6527406/ReadBinary.pm.diff.txt)
@briandfoy
Copy link
Owner

Okay, noted. I'll need to investigate.

@DannyThomas
Copy link
Author

DannyThomas commented May 25, 2021 via email

@briandfoy briandfoy self-assigned this May 25, 2021
@briandfoy
Copy link
Owner

I played around with this and couldn't get anything to make 128-bit integers.

There's a lot I could do here, but I'm curious about the sign issue. We can't simply ignore the top bytes because that may be where the sign bit is. But, maybe those octets really don't matter and the sign bit is with the lower 64 bits.

If you can create a file with a 128-bit, let me know. I'd like to look at it, especially if it's a binary plist.

@briandfoy briandfoy added Status: needs help needs outside expertise or capacity Status: stalled something is blocking progress labels Jul 6, 2021
@briandfoy
Copy link
Owner

Just an update - I have some local code that I haven't pushed because I don't like it yet, and I'm kinda waiting for more complaints. If this is pressing, I can spend more time on it, but there always seems to be more pressing things. It's a good report and I'm not blocked on anything other than time.

@DannyThomas
Copy link
Author

DannyThomas commented Jan 22, 2022 via email

briandfoy added a commit that referenced this issue Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: needs help needs outside expertise or capacity Status: stalled something is blocking progress
Projects
None yet
Development

No branches or pull requests

2 participants