Bug 142391 - Use binary image format 0x13 only when necessary, to allow compatibility with other suites
Summary: Use binary image format 0x13 only when necessary, to allow compatibility with...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.0.3.2 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.6.0
Keywords: difficultyInteresting, easyHack, skillCpp
: 142405 (view as bug list)
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2021-05-20 09:46 UTC by Mike Kaganski
Modified: 2023-07-11 13:47 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Test file from i#64377 (172.06 KB, application/vnd.oasis.opendocument.text)
2021-05-20 10:12 UTC, Mike Kaganski
Details
Test file with password on macro (174.69 KB, application/vnd.oasis.opendocument.text)
2021-07-01 07:27 UTC, Tarun Sharma
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-05-20 09:46:49 UTC
https://bz.apache.org/ooo/show_bug.cgi?id=64377 took great effort to assure compatibility when using new large image (binary format 0x12 - see basic/source/inc/filefmt.hxx). Every OOo, LO and AOO versions since 2006 can use that format without problems. This had prepared grounds to finally start using this binary format in ODF, allowing to remove the limitation of module size in password-protected libraries.

However, LibreOffice now uses incompatible binary format 0x13, which was introduced in version 5.0.3 and 5.1 in tdf#94617. Since 5.2 (tdf#87530), that format is written into ODF. This makes the image unusable for any other suite.

The proposal here is only use binary format 0x13 when actually needed, i.e. when there are methods starting at an offset that would overflow 16 bits, and use format 0x12 in other cases. That would make the resulting binary compatible with ~100% OOo derivatives used today *wherever possible* (and when there is such a method that requires use of format 0x13, use of incompatible format would be justified, since such a module would be impossible to use in those versions/derivatives anyway).

The warning that appears when saving such a module should explicitly mention compatibility issues.

See also tdf#92620.

The code pointers are in the related change https://git.libreoffice.org/core/+/ddb45261590939d884ac2bcb1fd258de7b2370da that introduced 0x13.
Comment 1 Mike Kaganski 2021-05-20 10:12:14 UTC
Created attachment 172193 [details]
Test file from i#64377

Steps for testing:

1. Open the attached document in LibreOffice >= 5.2; allow macros
2. In Basic IDE, Tools->Select Module
3. On Libraries tab, choose "test-ray-bigmodule.odt" in Location drop-down list
4. Select Xray library, click on Password button, set some password -> OK
5. Close the dialog and IDE
6. Save the document (accept the warning telling about module _Main, which is too large to store in binary format by pressing OK).
7. Reopen the document, check that pressing Button starts Xray; check that Xray module is password-protected.
8. Try to do the same in LibreOffice 5.1, or in AOO (the button does not work).
Comment 2 Mike Kaganski 2021-05-20 10:13:43 UTC
(In reply to Mike Kaganski from comment #1)
> 8. Try to do the same in LibreOffice 5.1, or in AOO (the button does not
> work).

Sorry, a thinko: LibreOffice before 5.0.3 was meant (so e.g., LibreOffice 5.0.2 or 4.4).
Comment 3 Tarun Sharma 2021-06-30 13:09:42 UTC
I was looking to work on this issue and was following the steps you mentioned and

> Save the document (accept the warning telling about module _Main, which is too large to store in binary format by pressing OK)

But i didn't got this error message on saving the document. 


> 1. Open the attached document in LibreOffice >= 5.2;

I'm using 7.2 Libreoffice
Comment 4 Mike Kaganski 2021-06-30 14:00:39 UTC
(In reply to Tarun Sharma from comment #3)
> But i didn't got this error message on saving the document. 

Which would mean that you didn't set the password, as mentioned in step 4 of comment 1. If you are sure you have followed all steps carefully, then please attach the resulting file.
Comment 5 Tarun Sharma 2021-07-01 07:27:05 UTC
Created attachment 173302 [details]
Test file with password on macro
Comment 6 Tarun Sharma 2021-07-01 07:28:18 UTC
attachment 173302 [details]

Yes i have followed every step and didn't got the warning. Tried for the second time also. 

https://imgur.com/a/wKcMSMN . <- Here I'm getting old password enabled as i have set a password. Also ii'm attaching the file.
Comment 7 Mike Kaganski 2021-07-01 07:31:05 UTC
(In reply to Tarun Sharma from comment #6)
> Yes i have followed every step and didn't got the warning. Tried for the
> second time also. 

No you didn't :-D

> https://imgur.com/a/wKcMSMN . <- Here I'm getting old password enabled as i
> have set a password. Also ii'm attaching the file.

Yes, and the screenshot shows exactly where you didn't follow the steps: comment 1 step 3.
Comment 8 Tarun Sharma 2021-07-01 07:44:22 UTC
Okk, yess sorry got the warning didn;t select xray from the dropdown.
Comment 9 Tarun Sharma 2021-07-02 12:03:17 UTC
Hi 

Maybe a noob question but 
I was looking in to the proposal and i was kinda stuck on binary format 0x12 or 0x13. Is it like (in binary 19 ) it has 19 bit for 0x13 ? 

What does it represent/ ?
Comment 10 Mike Kaganski 2021-07-02 12:41:32 UTC
(In reply to Tarun Sharma from comment #9)

I'm sorry, I don't quite understand the question.
What "in binary 19" means? "it has 19 bit for 0x13" - what is "it", what "19 bit" are meant? 0x13 is indeed decimal 19, but I fail to see other relation of the mentioned numbers.

"What does it represent/ ?" - what is "it" in the question? I suspect you ask about the number in the version - then it should be described in basic/source/inc/filefmt.hxx, which is mentioned in comment 0...
Comment 11 Tarun Sharma 2021-07-03 13:48:24 UTC
sorry for bad phrasing of the question. 

i wanted to know what is binary format 0x13 ?
Comment 12 Mike Kaganski 2021-07-03 20:04:22 UTC
(In reply to Tarun Sharma from comment #11)

That is the number of the binary image version, described in basic/source/inc/filefmt.hxx.
Comment 13 Tarun Sharma 2021-08-02 08:46:59 UTC
Hi Mike 

I wasn't able to understand from the attached  links that how to resolve this issue. 

I reverted the changes in sbxmod.cxx, like it was before the introduction of 0x13 https://git.libreoffice.org/core/+/ddb45261590939d884ac2bcb1fd258de7b2370da 

but still was getting the warning in xRay. 

Can i get more help in this!?
Comment 14 Andreas Heinisch 2023-03-23 15:37:00 UTC
*** Bug 142405 has been marked as a duplicate of this bug. ***
Comment 15 Commit Notification 2023-03-28 07:37:52 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d622972dceba40d89852b1dc832c6e2a4612b2fa

tdf#142391 - Store method using 0x13 format only when actually needed

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Mike Kaganski 2023-07-11 13:47:27 UTC
(In reply to Commit Notification from comment #15)

Thanks Andreas!
FTR: with this commit, we factually disabled writing pre-0x12 images, i.e. OOo prior to v.2.2 will not be able to use the binary images saved by LibreOffice. Likely, it's not goint to upset lots of people :)