Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Allocate enough space for Unicode strings in binary property lists. #148

Merged
merged 1 commit into from
Oct 8, 2016

Conversation

grp
Copy link
Contributor

@grp grp commented Oct 8, 2016

Before, only half as much space as needed was allocated. Fixes #145.

@grp grp assigned sas and Ktwu Oct 8, 2016
@grp
Copy link
Contributor Author

grp commented Oct 8, 2016

This seems right and it makes parsing get (much) further, but I don't know this code that well.

Copy link
Contributor

@Ktwu Ktwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok getting this in to unblock William, but we really need to start writing unit tests.

@grp, can you follow this up with a test? Merging a test binary plist with some emojis in it and making we can parse out expected values seems good enough for now.

@@ -176,7 +176,7 @@ Create(void *opaque, ABPRecordType type, void *arg1, void *arg2, void *arg3)
if (ReadSeek(opaque, offset, SEEK_SET) < 0)
return nullptr;

string.resize(nchars);
string.resize(sizeof(char) * nchars);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: both here and for UTF16, use something like 'size_t stringsize = sizeof(foo) * nchar'

@grp
Copy link
Contributor Author

grp commented Oct 8, 2016

I'll add a test, although I'm not sure how to check anything except that it doesn't violate ASAN. With #131 that should be enough though.

Before, only half as much space as needed was allocated.
@grp grp force-pushed the grp/binary-asan branch from 57ac06a to b1e3a0d Compare October 8, 2016 17:31
@grp
Copy link
Contributor Author

grp commented Oct 8, 2016

Test added. Turns out it didn't decode the right string before either so the test did fail before the fix.

@Ktwu
Copy link
Contributor

Ktwu commented Oct 8, 2016

Lgtm

@Ktwu Ktwu closed this Oct 8, 2016
@Ktwu
Copy link
Contributor

Ktwu commented Oct 8, 2016

Sorry, finger slipped in mobile ui. Merge at your leisure.

@Ktwu Ktwu reopened this Oct 8, 2016
@grp grp merged commit f4d5004 into master Oct 8, 2016
@grp grp deleted the grp/binary-asan branch October 8, 2016 18:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants