Put size check before data dereference
[vlc/asuraparaju-public.git] / projects / activex / objectsafety.cpp
blob667a15bd4683ae3d5c430e8608a90f4853e52798
1 /*****************************************************************************
2 * objectsafety.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005-2010 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include "plugin.h"
24 #include "objectsafety.h"
26 #include "axvlc_idl.h"
28 #if 0
29 const GUID IID_IObjectSafety =
30 {0xCB5BDC81,0x93C1,0x11cf,{0x8F,0x20,0x00,0x80,0x5F,0x2C,0xD0,0x64}};
31 #endif
33 using namespace std;
35 STDMETHODIMP VLCObjectSafety::GetInterfaceSafetyOptions(
36 REFIID riid,
37 DWORD *pdwSupportedOptions,
38 DWORD *pdwEnabledOptions
41 if( (NULL == pdwSupportedOptions) || (NULL == pdwEnabledOptions) )
42 return E_POINTER;
44 *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACESAFE_FOR_UNTRUSTED_CALLER;
46 if( (IID_IDispatch == riid)
47 || (IID_IVLCControl == riid)
48 || (IID_IVLCControl2 == riid) )
50 *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER;
51 return NOERROR;
53 else if( (IID_IPersist == riid)
54 || (IID_IPersistStreamInit == riid)
55 || (IID_IPersistStorage == riid)
56 || (IID_IPersistPropertyBag == riid) )
58 *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA;
59 return NOERROR;
61 *pdwEnabledOptions = 0;
62 return E_NOINTERFACE;
65 STDMETHODIMP VLCObjectSafety::SetInterfaceSafetyOptions(
66 REFIID riid,
67 DWORD dwOptionSetMask,
68 DWORD dwEnabledOptions
71 if( (IID_IDispatch == riid)
72 || (IID_IVLCControl == riid)
73 || (IID_IVLCControl2 == riid) )
75 if( (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwOptionSetMask)
76 && (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwEnabledOptions) )
78 return NOERROR;
80 return E_FAIL;
82 else if( (IID_IPersist == riid)
83 || (IID_IPersistStreamInit == riid)
84 || (IID_IPersistStorage == riid)
85 || (IID_IPersistPropertyBag == riid) )
87 if( (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwOptionSetMask)
88 && (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwEnabledOptions) )
90 return NOERROR;
92 return E_FAIL;
94 return E_FAIL;