OLE file corruption
I'm not sure what exactly is the content of the GSF_META_NAME_DOCUMENT_PARTS property in the attached file but it was created using Power Point and is valid.
The application gets input compound file and creates an output compound file with altered properties on the DocumentSummaryInfo stream.
Flow:
- Copy all streams besides for DocumentSummaryInfo stream
- Copy the input DocumentSummaryInfo stream to a temporary stream
- Add/Remove properties from the temporary stream
- Write the temporarty stream to the output file
This is the code (It's actually spread through some files so I hope I didn't miss anything)
file = gsf_output_istream_new(mStream.get(), error.GetCleanError());
storage = gsf_outfile_msole_new(GSF_OUTPUT(file));
gsf_output_set_name(GSF_OUTPUT(storage), "Root");
// get the DocumentSummaryInfo stream content from the input file to a temporary stream
auto infile = gsf_infile_child_by_name(GSF_INFILE(storage), "\05DocumentSummaryInformation");
temp_stream = unique_ptr<GsfDocMetaData, GsfDocMetaData_deleter>(gsf_doc_meta_data_new());
gsf_doc_meta_data_read_from_msole(temp_stream.get(), infile)
// append/remove properties to the temp stream
auto out_stream = GSF_OUTPUT(gsf_outfile_new_child(GSF_OUTFILE(storageOutput), "\05DocumentSummaryInformation", false));
// gsf_doc_meta_data_insert(temp_stream.get(), g_strdup(name.c_str()), gvalue.release()); // writing some property, but the bug reproduces even without this line
// Write the temp stream to the output stream
gsf_doc_meta_data_write_to_msole(temp_stream.get(), out_stream, true); // this line corrupts the file
If GSF_META_NAME_DOCUMENT_PARTS is removed prior to writing the metadata:
const auto extraPropertiesToRemvoe = string(GSF_META_NAME_DOCUMENT_PARTS);
gsf_doc_meta_data_remove(temp_stream.get(), extraPropertiesToRemvoe.c_str());
(or by using CFX for example), the output is valid, hence the assumption the issue is this property.
Besides for this specific issue the application performs great and we didn't encounter any other issue so far with adding/removing properties from files using the library.