Issue 124661 - crash when loading and re-saving attached ppt file with a single customshape
Summary: crash when loading and re-saving attached ppt file with a single customshape
Status: CLOSED FIXED
Alias: None
Product: Impress
Classification: Application
Component: save-export (show other issues)
Version: 4.1.0-dev
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.2.0
Assignee: Armin Le Grand
QA Contact:
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2014-04-11 15:16 UTC by Armin Le Grand
Modified: 2017-05-20 10:35 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.0-dev
Developer Difficulty: ---


Attachments
minimized exaple file causing the crash (128.00 KB, application/vnd.ms-powerpoint)
2014-04-11 15:16 UTC, Armin Le Grand
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Armin Le Grand 2014-04-11 15:16:55 UTC
Created attachment 83172 [details]
minimized exaple file causing the crash

To create the crash: Load attached ppt and save as (to be able to reuse the file) also as ppt -> crash

Reason is that the contained single customshape seems to have a wrong definition or is wrongly imported (not sure yet). The formula contains references to object 196 (?196), but has only 150 definition lines. This leads to mem accesses out of bound in ConvertEnhancedCustomShapeEquation. A first change to avoid that already survives the crash, but does not yet identify the root of the problem. Nonetheless, out of bound accesses are always good to avoid.
Comment 1 Armin Le Grand 2014-04-11 15:17:44 UTC
First is to avoid out of bound access, adding that...
Comment 2 Armin Le Grand 2014-04-11 15:27:07 UTC
Checking the bounds and not accessing when out of bounds makes the save survive and looks good in ppt. Added an assertion, too. Preparing commit of this 1st change.
This is not yet fixed, but without the crash afetr that. Keep open due to identifying the cause of this is needed.
Comment 3 SVN Robot 2014-04-11 15:29:36 UTC
"alg" committed SVN revision 1586681 into trunk:
i124661 secure possible out of bound access to stl vector content
Comment 4 Steve Yin 2014-04-14 09:44:12 UTC
Found a related issue: https://issues.apache.org/ooo/show_bug.cgi?id=112309
Comment 5 Steve Yin 2014-04-15 07:58:29 UTC
I found Symphony made a partial fix on custom shape for PPT compatibility issue before 2009. But I cannot get more information from the defect DB or related developers. Keep going.
Comment 6 Armin Le Grand 2014-04-15 08:59:47 UTC
Hi Steve, thanks for the info. Hopefully you can find something, help always appreciated. For reference, I checked with the minimal file and after re-export to ppt and opening in MS ppt 2003 it looks okay, I can see no obvious deformations/errors.
Comment 7 Steve Yin 2014-04-15 10:12:22 UTC
@Armin: The exported file by AOO cannot show in MSO 2010.

I found another root cause. The number of equations (pGuides_complex) in the sample file is 137. This value should not be exceed 128. I think the sample file should be deemed with a bad equations array and should not apply these equations to the shape when importing.

I tested on my local machine. The exporting file can be opened by MSO 2010 normally.
Comment 8 Steve Yin 2014-04-15 10:14:38 UTC
Add the submit info here.

Revision: 1587496
Author: steve_y
Date: Tuesday, April 15, 2014 6:12:14 PM
Message:
Issue 124661 - crash when loading and re-saving attached ppt file with a single customshape

check the equation array element number. If the number is greater than 128, the equation array will not be imported.
----
Modified : /openoffice/trunk/main/filter/source/msfilter/msdffimp.cxx
Comment 9 SVN Robot 2014-04-15 10:18:38 UTC
"steve_y" committed SVN revision 1587496 into trunk:
Issue 124661 - crash when loading and re-saving attached ppt file with a sing...
Comment 10 Armin Le Grand 2014-04-15 11:39:26 UTC
Hi steve, thanks for the fix. But why '128' ? Is there really a fixed limit for PPT CustomShape formula equations? Shouldn't it be compared with the (hopefully known) number of entries in the current formula, at least when that number is less than 128...?
Comment 11 Steve Yin 2014-04-15 14:55:16 UTC
Hi Armin. This limit is from [MS-ODRAW] (Office Drawing Binary File Format Structure Specification). In its chapter 2.3.6.27, pGuides_complex. It said that "pGuides_complex (variable): An IMsoArray record of SG records that specifies a set of values that are used to define the geometry of this shape. This array MUST NOT have more than 128 elements."

Maybe 128 equations for one custom shape is enough?

And I didn't see MSO 2010 applies the equations to the shape, I think it may ignore the equations in some way when importing the sample file and keep them when saving.
Comment 12 Armin Le Grand 2014-04-15 15:54:45 UTC
Hi Steve, thanks for the infos. I am surprised (well, not too much) that it was defined to be limited from the start.
What I wanted to point at is that comparing to that is okay, but when only 20 entries are used, one referring 21 is already wrong, too (AFAIK). Would it not be better to compare to the minimum of the limit of 128 and the (hopefully known) number of entries in the current formula list in the fix?
Comment 13 Steve Yin 2014-04-16 07:47:40 UTC
Hi Armin. Yes, agree with you.
Comment 14 SVN Robot 2014-04-16 07:48:59 UTC
"steve_y" committed SVN revision 1587823 into trunk:
Issue 124661 - crash when loading and re-saving attached ppt file with a sing...
Comment 15 Rainer Bielefeld 2014-04-20 08:15:52 UTC
(a) already Reproducible with AOO 4.0.0
(b) Still worked without crash with 
    * server installation of "AOO 3.4.1 – German UI / German locale 
      [AOO341m1(Build:9593) - Rev.1372282]" on German WIN7 Home Premium (64bit)", 
      own separate user profile
    * sever installation of "OOo 3.3.0 English UI
      / German locale [OOO330m20 (Build 9567)]" on WIN7 Home Premium (64bit) DE
Comment 16 Armin Le Grand 2014-04-22 15:48:30 UTC
Hi Steve, sorry for the hassle, I mixed up things. I thought you already found the place where the import of the malicious shape takes place, and there it would be possible to know the number of lines in the formula and to correct against that. Please ignore comment 12 and thanks for still enhancing the current fix!
Comment 17 Steve Yin 2014-04-23 03:51:20 UTC
Hi Armin. You're welcome. I did not find the place in AOO source code. I am very suspicious of the sample file which may contains some incorrect equations and the total number of its equations is also exceeding the limit. So I think it should be simply dropped. 

(In reply to Armin Le Grand from comment #16)
> Hi Steve, sorry for the hassle, I mixed up things. I thought you already
> found the place where the import of the malicious shape takes place, and
> there it would be possible to know the number of lines in the formula and to
> correct against that. Please ignore comment 12 and thanks for still
> enhancing the current fix!
Comment 18 Armin Le Grand 2014-04-29 09:37:40 UTC
To resolved, crash is fixed. Additional thanks to Steve Yin!