FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Tweak the writing of offsets when writing user defined properties by Numpsy · Pull Request #106 · openmcdf/openmcdf · GitHub

Tweak the writing of offsets when writing user defined properties - #106

Merged
ironfede merged 1 commit into
openmcdf:masterfrom
Numpsy:users/rw/user_defined_2
Feb 25, 2024
Merged

ironfede merged 1 commit into
openmcdf:masterfrom
Numpsy:users/rw/user_defined_2

Conversation

Numpsy commented Feb 10, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

As per the Microsoft documentation at https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-oshared/fe59ffd9-79e9-44fb-a1c9-2466057b05c6 -

The total size of this property set’s PropertySet structure ([MS-OLEPS] section [2.20](https://learn.microsoft.com/en-us/openspecs/windows_protocols/MS-OLEPS/aefcbddf-f299-4f5e-a9da-65ce4ca55075)) MUST be padded to a multiple of 4 bytes

but the padding code was commented out?
When debugging an attempt at writing the user defined properties, I had a case where the size ended up at 299 bytes when it should really be padded up to 300, and I think this fixes that.

@@note@@ It might need additional padding adding to the end of the user defined section, but the documents I'm testing with are all ending up with the size a multiple of 4 with no padding, so I don't yet have a test for that case.


int size1 = (int)(bw.BaseStream.Position - oc1.OffsetPS);

bw.Seek(oc1.OffsetPS + 4, System.IO.SeekOrigin.Begin);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This +4 was causing it to overwrite the property count rather than the size (I ended up with a size of 0 and >100 properties, which is just wrong)

bw.Seek((int)oc1.PropertyIdentifierOffsets[i], System.IO.SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Write(oc1.PropertyOffsets[i] - oc1.OffsetPS);
bw.Seek((int)oc1.PropertyIdentifierOffsets[i] + 4, System.IO.SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Write((int)(oc1.PropertyOffsets[i] - oc1.OffsetPS));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Changed this to match the case on lines 207/208, otherwise it was writing the offset in the wrong place, and also writing 8 bytes rather than 4

Numpsy force-pushed the users/rw/user_defined_2 branch from 1fea0aa to 3b3b33f Compare February 13, 2024 00:07

Copy link
Copy Markdown
Collaborator

@Numpsy , do you have a test case to add as a unit test for this PR? Thanks!

ironfede merged commit 4d660b9 into openmcdf:master Feb 25, 2024

Numpsy commented Feb 25, 2024

Copy link
Copy Markdown
Contributor Author

I've been working with a few unit tests locally, but it was a bit hard to do them for each PR because you need both this one and the dictionary ones to write all the required data.
I'll get everything synched up, and try to add tests for all the cases.

Thanks for merging the changes :-)

Numpsy deleted the users/rw/user_defined_2 branch February 25, 2024 21:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL