clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name sddetect.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/sd/inc -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sd/source/ui/unoidl/sddetect.cxx
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | #include "sddetect.hxx" |
21 | |
22 | #include <com/sun/star/beans/PropertyValue.hpp> |
23 | #include <cppuhelper/supportsservice.hxx> |
24 | #include <com/sun/star/io/XInputStream.hpp> |
25 | #include <com/sun/star/ucb/ContentCreationException.hpp> |
26 | #include <com/sun/star/uno/XComponentContext.hpp> |
27 | #include <vcl/graphicfilter.hxx> |
28 | #include <sfx2/docfile.hxx> |
29 | #include <sfx2/docfilt.hxx> |
30 | #include <sfx2/fcontnr.hxx> |
31 | #include <vcl/FilterConfigItem.hxx> |
32 | #include <sot/storage.hxx> |
33 | #include <unotools/mediadescriptor.hxx> |
34 | |
35 | using namespace ::com::sun::star; |
36 | using namespace ::com::sun::star::uno; |
37 | using namespace ::com::sun::star::io; |
38 | using namespace ::com::sun::star::task; |
39 | using namespace ::com::sun::star::beans; |
40 | using namespace ::com::sun::star::lang; |
41 | using utl::MediaDescriptor; |
42 | |
43 | SdFilterDetect::SdFilterDetect() |
44 | { |
45 | } |
46 | |
47 | SdFilterDetect::~SdFilterDetect() |
48 | { |
49 | } |
50 | |
51 | OUString SAL_CALL SdFilterDetect::detect( Sequence< beans::PropertyValue >& lDescriptor ) |
52 | { |
53 | MediaDescriptor aMediaDesc( lDescriptor ); |
54 | OUString aTypeName = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_TYPENAME(), OUString() ); |
55 | uno::Reference< io::XInputStream > xInStream ( aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()], uno::UNO_QUERY ); |
56 | if ( !xInStream.is() ) |
| |
57 | return OUString(); |
58 | |
59 | SfxMedium aMedium; |
60 | aMedium.UseInteractionHandler( false ); |
61 | aMedium.setStreamToLoadFrom( xInStream, true ); |
62 | |
63 | SvStream *pInStrm = aMedium.GetInStream(); |
64 | if ( !pInStrm || pInStrm->GetError() ) |
| 2 | | Assuming 'pInStrm' is non-null | |
|
| |
65 | return OUString(); |
66 | |
67 | if ( aTypeName.startsWith( "impress_MS_PowerPoint_97" ) ) |
| |
68 | { |
69 | |
70 | |
71 | |
72 | |
73 | pInStrm->Seek( STREAM_SEEK_TO_BEGIN ); |
74 | if ( pInStrm->remainingSize() == 0 ) |
| 5 | | Assuming the condition is false | |
|
| |
75 | return OUString(); |
76 | |
77 | try |
78 | { |
79 | tools::SvRef<SotStorage> aStorage = new SotStorage( pInStrm, false ); |
| |
80 | if ( !aStorage->GetError() && aStorage->IsStream( "PowerPoint Document" ) ) |
| |
81 | return aTypeName; |
82 | } |
83 | catch (const css::ucb::ContentCreationException&) |
84 | { |
85 | } |
86 | } |
87 | else |
88 | { |
89 | pInStrm->Seek( STREAM_SEEK_TO_BEGIN ); |
90 | |
91 | const OUString aFileName( aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() ) ); |
92 | GraphicDescriptor aDesc( *pInStrm, &aFileName ); |
93 | if( !aDesc.Detect() ) |
94 | { |
95 | INetURLObject aCheckURL( aFileName ); |
96 | if( aCheckURL.getExtension().equalsIgnoreAsciiCase("cgm") ) |
97 | { |
98 | sal_uInt8 n8; |
99 | pInStrm->Seek( STREAM_SEEK_TO_BEGIN ); |
100 | pInStrm->ReadUChar( n8 ); |
101 | if ( ( n8 & 0xf0 ) == 0 ) |
102 | |
103 | |
104 | return "impress_CGM_Computer_Graphics_Metafile"; |
105 | } |
106 | } |
107 | else |
108 | { |
109 | OUString aShortName( GraphicDescriptor::GetImportFormatShortName( aDesc.GetFileFormat() ) ); |
110 | GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter(); |
111 | const OUString aName( rGrfFilter.GetImportFormatTypeName( rGrfFilter.GetImportFormatNumberForShortName( aShortName ) ) ); |
112 | |
113 | if ( aShortName.equalsIgnoreAsciiCase( "PCD" ) ) |
114 | { |
115 | sal_Int32 nBase = 2; |
116 | if ( aTypeName == "pcd_Photo_CD_Base4" ) |
117 | nBase = 1; |
118 | else if ( aTypeName == "pcd_Photo_CD_Base16" ) |
119 | nBase = 0; |
120 | FilterConfigItem aFilterConfigItem( "Office.Common/Filter/Graphic/Import/PCD" ); |
121 | aFilterConfigItem.WriteInt32( "Resolution" , nBase ); |
122 | } |
123 | |
124 | SfxFilterMatcher aMatch("sdraw"); |
125 | std::shared_ptr<const SfxFilter> pFilter = aMatch.GetFilter4FilterName( aName ); |
126 | if ( pFilter ) |
127 | return pFilter->GetRealTypeName(); |
128 | } |
129 | } |
130 | |
131 | return OUString(); |
| 9 | | Potential leak of memory pointed to by 'aStorage.pObj' |
|
132 | } |
133 | |
134 | |
135 | OUString SAL_CALL SdFilterDetect::getImplementationName() |
136 | { |
137 | return "com.sun.star.comp.draw.FormatDetector"; |
138 | } |
139 | |
140 | |
141 | sal_Bool SAL_CALL SdFilterDetect::supportsService( const OUString& sServiceName ) |
142 | { |
143 | return cppu::supportsService(this, sServiceName); |
144 | } |
145 | |
146 | |
147 | Sequence< OUString > SAL_CALL SdFilterDetect::getSupportedServiceNames() |
148 | { |
149 | return { "com.sun.star.frame.ExtendedTypeDetection" }; |
150 | } |
151 | |
152 | |
153 | extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* |
154 | com_sun_star_comp_draw_FormatDetector_get_implementation(css::uno::XComponentContext*, |
155 | css::uno::Sequence<css::uno::Any> const &) |
156 | { |
157 | return cppu::acquire(new SdFilterDetect()); |
158 | } |
159 | |
160 | |