[origin import] legend read as annotation, memory corruption
The projecttwo-layer.opj is not properly read. AddressSanitizer is reporting a stack-buffer-overflow which can also be reproduced with the test ProjectImportTest::testOriginMultiLayersAsCoordinateSystems(). The plot legend in Origin's file is read as a text label (annotation) which is wrong.
void ProjectParser::importTo(Folder*, const QStringList&), starting import of /builds/education/labplot/tests/import_export/Project/data/two_layers_as_two_coordinate_systems.opj
virtual bool OriginProjectParser::load(Project*, bool)
=================================================================
==7317==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fb0983f0622 at pc 0x000003137611 bp 0x7ffe17991dc0 sp 0x7ffe17991db8
READ of size 1 at 0x7fb0983f0622 thread T0
#0 0x3137610 in OriginAnyParser::getAnnotationProperties(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int) /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:1844
#1 0x313a185 in OriginAnyParser::readAnnotationElement() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:659
#2 0x313b563 in OriginAnyParser::readAnnotationList() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:563
#3 0x313b563 in OriginAnyParser::readLayerElement() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:491
#4 0x313c4b8 in OriginAnyParser::readWindowElement() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:448
#5 0x313e163 in OriginAnyParser::parse() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:144
#6 0x30c0d56 in OriginFile::parse() /builds/education/labplot/src/3rdparty/liborigin/OriginFile.cpp:178
#7 0x1ab8998 in OriginProjectParser::load(Project*, bool) /builds/education/labplot/src/backend/datasources/projects/OriginProjectParser.cpp:191
#8 0xf851e3 in ProjectParser::importTo(Folder*, QList<QString> const&) /builds/education/labplot/src/backend/datasources/projects/ProjectParser.cpp:73
#9 0x9240c5 in ProjectImportTest::testOriginMultiLayersAsCoordinateSystem() /builds/education/labplot/tests/import_export/Project/ProjectImportTest.cpp:660
#10 0x92171c in ProjectImportTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /builds/education/labplot/_build/tests/import_export/Project/ProjectImportTest_autogen/EWIEGA46WW/moc_ProjectImportTest.cpp:191
#11 0x7fb09f4630ce in QMetaMethodInvoker::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x19e0ce) (BuildId: 93a84844f2e327a3ad79997eba1bc06c533deb33)
#12 0x7fb09f463b61 in QMetaMethod::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x19eb61) (BuildId: 93a84844f2e327a3ad79997eba1bc06c533deb33)
#13 0x7fb09f8f6431 (/lib64/libQt6Test.so.6+0x27431) (BuildId: 6624593e1a52e29a563fe5313a10db1fac7bf428)
#14 0x7fb09f900e69 in QTest::qRun() (/lib64/libQt6Test.so.6+0x31e69) (BuildId: 6624593e1a52e29a563fe5313a10db1fac7bf428)
#15 0x7fb09f8f940a in QTest::qExec(QObject*, int, char**) (/lib64/libQt6Test.so.6+0x2a40a) (BuildId: 6624593e1a52e29a563fe5313a10db1fac7bf428)
#16 0x87c19b in main /builds/education/labplot/tests/import_export/Project/ProjectImportTest.cpp:761
#17 0x7fb09ed941af in __libc_start_call_main (/lib64/libc.so.6+0x281af) (BuildId: bbeee08e5f56966e641c4f3ba4ea1da9d730d0ab)
#18 0x7fb09ed94278 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x28278) (BuildId: bbeee08e5f56966e641c4f3ba4ea1da9d730d0ab)
#19 0x9214e4 in _start ../sysdeps/x86_64/start.S:115
Address 0x7fb0983f0622 is located in stack of thread T0 at offset 546 in frame
#0 0x31392bf in OriginAnyParser::readAnnotationElement() /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:571
This frame has 19 object(s):
[32, 33) '<unknown>'
[48, 49) '<unknown>'
[64, 65) '<unknown>'
[80, 81) '<unknown>'
[96, 112) '<unknown>'
[128, 144) '<unknown>'
[160, 176) '<unknown>'
[192, 208) '<unknown>'
[224, 240) '<unknown>'
[256, 272) '<unknown>'
[288, 304) '<unknown>'
[320, 352) 'ane_header' (line 588)
[384, 416) 'name' (line 591)
[448, 480) '<unknown>'
[512, 544) 'andt1_data' (line 607) <== Memory access at offset 546 overflows this variable
[576, 608) 'andt2_data' (line 621)
[640, 672) '<unknown>'
[704, 736) '<unknown>'
[768, 800) 'andt3_data' (line 653)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /builds/education/labplot/src/3rdparty/liborigin/OriginAnyParser.cpp:1844 in OriginAnyParser::getAnnotationProperties(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)
Shadow bytes around the buggy address:
0x7fb0983f0380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7fb0983f0400: f1 f1 f1 f1 f8 f2 f8 f2 01 f2 f8 f2 f8 f8 f2 f2
0x7fb0983f0480: f8 f8 f2 f2 f8 f8 f2 f2 00 00 f2 f2 00 00 f2 f2
0x7fb0983f0500: f8 f8 f2 f2 f8 f8 f2 f2 00 00 00 00 f2 f2 f2 f2
0x7fb0983f0580: 00 00 00 00 f2 f2 f2 f2 f8 f8 f8 f8 f2 f2 f2 f2
=>0x7fb0983f0600: 00 00 00 00[f2]f2 f2 f2 00 00 00 00 f2 f2 f2 f2
0x7fb0983f0680: 00 00 00 00 f2 f2 f2 f2 f8 f8 f8 f8 f2 f2 f2 f2
0x7fb0983f0700: 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00
0x7fb0983f0780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7fb0983f0800: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x7fb0983f0880: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Edited by Alexander Semke