Bug 116999 - Libreoffice command line interface is not opening cgm files
Summary: Libreoffice command line interface is not opening cgm files
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.4.6.2 release
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:6.1.0 target:6.0.5 target:5.4....
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-13 18:54 UTC by Jack O'Sullivan
Modified: 2018-04-30 10:44 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
CGM File (31.04 KB, application/octet-stream)
2018-04-13 18:54 UTC, Jack O'Sullivan
Details
pdf generated (55.94 KB, application/pdf)
2018-04-14 09:21 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack O'Sullivan 2018-04-13 18:54:31 UTC
Created attachment 141343 [details]
CGM File

I use the soffice CLI to convert CGM (Computer Graphics Metafiles) to SVG and PDF. This was working in v5.3.5 but following an upgrade to 5.4.6 the tool is failing to open the cgm.

I am using the following command:

soffice --headless --convert-to pdf:draw_pdf_Export --outdir /tmp/OpenOfficeExportadc150ec-0504-4d4a-9591-8c48d95ff8c4/cgm /tmp/OpenOfficeExportadc150ec-0504-4d4a-9591-8c48d95ff8c4/content/cgm/binary_corvette.cgm

for the PDF and:

soffice --headless --convert-to svg:draw_svg_Export_Export --outdir /tmp/OpenOfficeExportadc150ec-0504-4d4a-9591-8c48d95ff8c4/cgm /tmp/OpenOfficeExportadc150ec-0504-4d4a-9591-8c48d95ff8c4/content/cgm/binary_corvette.cgm

for the SVG conversion.

I haven't changed these commands between versions. I have also tested this on a v6 release (I no longer have the exact release details) and it is also failing on that version.

My error output is just:

"null output: Error: source file could not be loaded".

I have attached an example file that was working with 5.3.5, but is now no longer working.

Thanks

Jack
Comment 1 Julien Nabet 2018-04-14 09:05:19 UTC
Caolán: after some gdb session, I saw that the pb was due to 
    187                 if (static_cast<sal_uIntPtr>(mpEndValidSource - (mpSource + mnParaSize)) <= nSize)
    188                     throw css::uno::Exception("attempt to read past end of input", nullptr);
from filter/source/graphicfilter/icgm/class4.cxx

If revert partially 34a7a7ff426dac55d62fc357cebbc0b22cd65c06 by replacing "<=" by "<" it works, pdf is created.

Any thoughts?
Comment 2 Julien Nabet 2018-04-14 09:21:59 UTC
Created attachment 141351 [details]
pdf generated

Jack: thought you might be interested in retrieving the pdf
Comment 3 Commit Notification 2018-04-14 10:17:33 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5bf410957994ec2acfec1fddb822934ed0965820

Related tdf#116999: log the exception (filter/icgm)

It will be available in 6.1.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 4 Julien Nabet 2018-04-14 10:18:49 UTC
Let's remove target since it's just adding some warn log.
Comment 5 Jack O'Sullivan 2018-04-16 08:22:27 UTC
Hey guys, thanks for the quick work on this, look forward to testing it out properly on 6.1.
Comment 6 Julien Nabet 2018-04-16 08:36:37 UTC
(In reply to Jack O'Sullivan from comment #5)
> Hey guys, thanks for the quick work on this, look forward to testing it out
> properly on 6.1.

It's not fixed yet. The patch which has been pushed is just to add some trace.
Comment 7 Caolán McNamara 2018-04-16 09:10:56 UTC
I think the len check is actually good. Its that we're using null terminated strings here and expect that we can add a zero at the end, which is possible in this specific case, but not in the general case if that field has filled with a number > the buffer size. So this has headed off disaster in the general case.

For the specific case I think what we can do is to rework this to not need to add a null terminator and just build an OUString directly from the known length
Comment 8 Commit Notification 2018-04-16 12:20:17 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fa060cd34421b857c2f30301eaae86da125c0b67

Resolves: tdf#116999 fix reading cgm text at record bounds

It will be available in 6.1.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2018-04-19 12:14:35 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a0c008175eee894f6b4a8975d6c0b4bec2592d08&h=libreoffice-6-0

Resolves: tdf#116999 fix reading cgm text at record bounds

It will be available in 6.0.5.

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

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2018-04-19 12:17:18 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=67d236252a743c77da4d929e95d5223454a47cd4&h=libreoffice-5-4

Resolves: tdf#116999 fix reading cgm text at record bounds

It will be available in 5.4.8.

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

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2018-04-30 10:44:15 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-4-7":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6e81ed76f8db486d680734937c815d32e6934306&h=libreoffice-5-4-7

Resolves: tdf#116999 fix reading cgm text at record bounds

It will be available in 5.4.7.

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

Affected users are encouraged to test the fix and report feedback.