Bug 135799 - Error loading user-defined type with fixed-type array data field from password-protected library
Summary: Error loading user-defined type with fixed-type array data field from passwor...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.1.0.3 release
Hardware: All Windows (All)
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:7.1.0 target:7.0.2
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2020-08-16 12:27 UTC by Kadet
Modified: 2020-09-16 12:07 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Database with a secure library (2.47 MB, application/zip)
2020-08-16 12:32 UTC, Kadet
Details
Password-protected library with custom type with array data field (12.95 KB, application/vnd.oasis.opendocument.text)
2020-08-16 19:15 UTC, Mike Kaganski
Details
The option with the secure library in which the collapse. (2.41 MB, application/zip)
2020-08-22 09:20 UTC, Kadet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kadet 2020-08-16 12:27:20 UTC
Description:
After installing password protection on the macro library (MyLibrary (built into the document)) when trying to load this library: 
ThisComponent.BasicLibraries.LoadLibrary("MyLibrary")
An error appears: Invalid value or data type.
Incompatible type. Library macros don't work.


Steps to Reproduce:
1.Download the Cyanopica ZIP archive.zip and unzip it (anywhere).
2.Import the Library1 library and move the StartSet module from It to the Standard global library (ReadMe.txt).
3.Launch the Cyanopica.odb database

Actual Results:
Error connecting the macro library with password protection.

Expected Results:
The database is being started. Opens and configures the main form for working with the database.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
If you remove password protection from the macro library, the database works normally.
Comment 1 Kadet 2020-08-16 12:32:44 UTC
Created attachment 164348 [details]
Database with a secure library

A database with a built-in mylibrary macro library that is password-protected. The password for the library is 111. To start the database, you need to import the startset macro model (from the attached Library1 library) to the Standard global library.
Comment 2 Mike Kaganski 2020-08-16 19:15:01 UTC
Created attachment 164360 [details]
Password-protected library with custom type with array data field

Reproducible.
This is caused by a fixed-type array data field in a custom type in the protected library.
The attachment is a minimal reproducer. It contains two libraries: Library1 (password-protected; password is "123" without quotes), and Standard. Library1 contains a single module with only one definition of a custom type:

> Type TFail
>   i(0) As Integer ' Fails when this password-protected library is loaded
> End Type

Library Standard contains sub Main, which only loads the password-protected library:

> Sub Main
>   ThisComponent.BasicLibraries.LoadLibrary("Library1")
> End Sub

This sub is executed when the button is clicked in the document.

The problem happens in SbiImage::Load (case FileOffset::UserTypes), which calls pTypeElem->PutObject.
Comment 3 Mike Kaganski 2020-08-16 19:47:29 UTC
Regression after https://git.libreoffice.org/core/+/8a7b7b7b72c299bc9a96815814c1452be7f662c1.
Comment 4 Mike Kaganski 2020-08-16 19:51:35 UTC
Or rather implementation error.
Comment 5 Mike Kaganski 2020-08-17 07:30:56 UTC
The reference code, which runs when the library is not protected, is in SbiParser::DefType.
Comment 6 Mike Kaganski 2020-08-17 19:12:00 UTC
https://gerrit.libreoffice.org/c/core/+/100877
Comment 7 Commit Notification 2020-08-17 20:04:16 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#135799: properly load arrays in user-defined types from image

It will be available in 7.1.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 8 Kadet 2020-08-22 09:19:06 UTC
When you try to unblock a protected library, the LO crashes.

ThisDatabaseDocument = ThisComponent
If ThisDatabaseDocument.BasicLibraries.isLibraryPasswordProtected("MyLibrary") Then ThisDatabaseDocument.BasicLibraries.verifyLibraryPassword("MyLibrary",Pass)

The library is not protected. It doesn't cause any errors, but the library remains unprotected.
If ( NOT ThisDatabaseDocument.BasicLibraries.isLibraryPasswordProtected("MyLibrary")) Then ThisDatabaseDocument.BasicLibraries.changeLibraryPassword("MyLibrary",Ps,Pass)
'
Comment 9 Kadet 2020-08-22 09:20:46 UTC
Created attachment 164549 [details]
The option with the secure library in which the collapse.
Comment 10 Kadet 2020-08-22 09:25:35 UTC
The latest version of the database (Cyanopica_pass) does not require additional libraries. You just need to unzip it and run it. If you have a global macro library named "MyLibrary", delete it or move it. Otherwise, the database will not work.
Comment 11 Commit Notification 2020-09-16 12:07:16 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

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

tdf#135799: properly load arrays in user-defined types from image

It will be available in 7.0.2.

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.