Commit 3b3779b2 authored by Noomen Hamza's avatar Noomen Hamza Committed by Alexandre Julliard

OleConvertOLESTREAMToIStorage fails (returns REGDB_E_CLASSNOTREG) when

the CLSID of the OLE object is not found in the registry. Fixed.
parent d88fbb7a
...@@ -457,6 +457,24 @@ HRESULT WINAPI CLSIDFromString16( ...@@ -457,6 +457,24 @@ HRESULT WINAPI CLSIDFromString16(
if (!s) if (!s)
s = "{00000000-0000-0000-0000-000000000000}"; s = "{00000000-0000-0000-0000-000000000000}";
else { /* validate the CLSID string */
if (strlen(s) != 38)
return CO_E_CLASSSTRING;
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
return CO_E_CLASSSTRING;
for (i=1; i<37; i++)
{
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
((s[i] >= 'a') && (s[i] <= 'f')) ||
((s[i] >= 'A') && (s[i] <= 'F')))
)
return CO_E_CLASSSTRING;
}
}
TRACE("%s -> %p\n", s, id); TRACE("%s -> %p\n", s, id);
...@@ -473,9 +491,6 @@ HRESULT WINAPI CLSIDFromString16( ...@@ -473,9 +491,6 @@ HRESULT WINAPI CLSIDFromString16(
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */ /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
if (strlen(s) != 38)
return OLE_ERROR_OBJECT;
p = (BYTE *) id; p = (BYTE *) id;
s++; /* skip leading brace */ s++; /* skip leading brace */
...@@ -933,13 +948,13 @@ HRESULT WINAPI CLSIDFromProgID16( ...@@ -933,13 +948,13 @@ HRESULT WINAPI CLSIDFromProgID16(
sprintf(buf,"%s\\CLSID",progid); sprintf(buf,"%s\\CLSID",progid);
if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) { if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
HeapFree(GetProcessHeap(),0,buf); HeapFree(GetProcessHeap(),0,buf);
return OLE_ERROR_GENERIC; return CO_E_CLASSSTRING;
} }
HeapFree(GetProcessHeap(),0,buf); HeapFree(GetProcessHeap(),0,buf);
buf2len = sizeof(buf2); buf2len = sizeof(buf2);
if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) { if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
RegCloseKey(xhkey); RegCloseKey(xhkey);
return OLE_ERROR_GENERIC; return CO_E_CLASSSTRING;
} }
RegCloseKey(xhkey); RegCloseKey(xhkey);
return CLSIDFromString16(buf2,riid); return CLSIDFromString16(buf2,riid);
......
...@@ -6401,11 +6401,7 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName ...@@ -6401,11 +6401,7 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
/* Get the CLSID */ /* Get the CLSID */
hRes = CLSIDFromProgID16(IStorageCompObj.strProgIDName, &(IStorageCompObj.clsid)); hRes = CLSIDFromProgID16(IStorageCompObj.strProgIDName, &(IStorageCompObj.clsid));
if(hRes != S_OK) if(hRes == S_OK)
{
hRes = REGDB_E_CLASSNOTREG;
}
else
{ {
HKEY hKey; HKEY hKey;
LONG hErr; LONG hErr;
...@@ -6422,17 +6418,13 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName ...@@ -6422,17 +6418,13 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
if(hErr != ERROR_SUCCESS)
{
hRes = REGDB_E_CLASSNOTREG;
}
} }
if(hRes == S_OK )
{
/* Write CompObj Structure to stream */ /* Write CompObj Structure to stream */
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown1, sizeof(IStorageCompObj.byUnknown1), NULL); hRes = IStream_Write(pStream, IStorageCompObj.byUnknown1, sizeof(IStorageCompObj.byUnknown1), NULL);
hRes = IStream_Write(pStream, &(IStorageCompObj.clsid) , sizeof(IStorageCompObj.clsid ), NULL);
WriteClassStm(pStream,&(IStorageCompObj.clsid));
hRes = IStream_Write(pStream, &(IStorageCompObj.dwCLSIDNameLength), sizeof(IStorageCompObj.dwCLSIDNameLength), NULL); hRes = IStream_Write(pStream, &(IStorageCompObj.dwCLSIDNameLength), sizeof(IStorageCompObj.dwCLSIDNameLength), NULL);
if(IStorageCompObj.dwCLSIDNameLength > 0) if(IStorageCompObj.dwCLSIDNameLength > 0)
{ {
...@@ -6449,7 +6441,6 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName ...@@ -6449,7 +6441,6 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
hRes = IStream_Write(pStream, IStorageCompObj.strProgIDName , IStorageCompObj.dwProgIDNameLength, NULL); hRes = IStream_Write(pStream, IStorageCompObj.strProgIDName , IStorageCompObj.dwProgIDNameLength, NULL);
} }
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown2 , sizeof(IStorageCompObj.byUnknown2), NULL); hRes = IStream_Write(pStream, IStorageCompObj.byUnknown2 , sizeof(IStorageCompObj.byUnknown2), NULL);
}
IStream_Release(pStream); IStream_Release(pStream);
} }
return hRes; return hRes;
......
...@@ -1519,9 +1519,51 @@ extern int WIN32_LastError; ...@@ -1519,9 +1519,51 @@ extern int WIN32_LastError;
#define CO_E_INIT_ONLY_SINGLE_THREADED 0x80004012 */ #define CO_E_INIT_ONLY_SINGLE_THREADED 0x80004012 */
#define CO_S_NOTALLINTERFACES 0x00080012 #define CO_S_NOTALLINTERFACES 0x00080012
#define CO_E_NOTINITIALIZED 0x800401F0 #define CO_E_NOTINITIALIZED 0x800401F0L
#define CO_E_ERRORINDLL 0x800401F9 #define CO_E_ALREADYINITIALIZED 0x800401F1L
#define CO_E_OBJISREG 0x800401FB #define CO_E_CANTDETERMINECLASS 0x800401F2L
#define CO_E_CLASSSTRING 0x800401F3L
#define CO_E_IIDSTRING 0x800401F4L
#define CO_E_APPNOTFOUND 0x800401F5L
#define CO_E_APPSINGLEUSE 0x800401F6L
#define CO_E_ERRORINAPP 0x800401F7L
#define CO_E_DLLNOTFOUND 0x800401F8L
#define CO_E_ERRORINDLL 0x800401F9L
#define CO_E_WRONGOSFORAPP 0x800401FAL
#define CO_E_OBJNOTREG 0x800401FBL
#define CO_E_OBJISREG 0x800401FCL
#define CO_E_OBJNOTCONNECTED 0x800401FDL
#define CO_E_APPDIDNTREG 0x800401FEL
#define CO_E_RELEASED 0x800401FFL
#define CO_E_FAILEDTOIMPERSONATE 0x80040200L
#define CO_E_FAILEDTOGETSECCTX 0x80040201L
#define CO_E_FAILEDTOOPENTHREADTOKEN 0x80040202L
#define CO_E_FAILEDTOGETTOKENINFO 0x80040203L
#define CO_E_TRUSTEEDOESNTMATCHCLIENT 0x80040204L
#define CO_E_FAILEDTOQUERYCLIENTBLANKET 0x80040205L
#define CO_E_FAILEDTOSETDACL 0x80040206L
#define CO_E_ACCESSCHECKFAILED 0x80040207L
#define CO_E_NETACCESSAPIFAILED 0x80040208L
#define CO_E_WRONGTRUSTEENAMESYNTAX 0x80040209L
#define CO_E_INVALIDSID 0x8004020AL
#define CO_E_CONVERSIONFAILED 0x8004020BL
#define CO_E_NOMATCHINGSIDFOUND 0x8004020CL
#define CO_E_LOOKUPACCSIDFAILED 0x8004020DL
#define CO_E_NOMATCHINGNAMEFOUND 0x8004020EL
#define CO_E_LOOKUPACCNAMEFAILED 0x8004020FL
#define CO_E_SETSERLHNDLFAILED 0x80040210L
#define CO_E_FAILEDTOGETWINDIR 0x80040211L
#define CO_E_PATHTOOLONG 0x80040212L
#define CO_E_FAILEDTOGENUUID 0x80040213L
#define CO_E_FAILEDTOCREATEFILE 0x80040214L
#define CO_E_FAILEDTOCLOSEHANDLE 0x80040215L
#define CO_E_EXCEEDSYSACLLIMIT 0x80040216L
#define CO_E_ACESINWRONGORDER 0x80040217L
#define CO_E_INCOMPATIBLESTREAMVERSION 0x80040218L
#define CO_E_FAILEDTOOPENPROCESSTOKEN 0x80040219L
#define CO_E_DECODEFAILED 0x8004021AL
#define CO_E_ACNOTINITIALIZED 0x8004021BL
#define OLE_E_FIRST 0x80040000L #define OLE_E_FIRST 0x80040000L
#define OLE_E_LAST 0x800400FFL #define OLE_E_LAST 0x800400FFL
...@@ -1640,7 +1682,11 @@ extern int WIN32_LastError; ...@@ -1640,7 +1682,11 @@ extern int WIN32_LastError;
/* registry errors */ /* registry errors */
#define REGDB_E_READREGDB 0x80040150 #define REGDB_E_READREGDB 0x80040150
#define REGDB_E_WRITEREGDB 0x80040151
#define REGDB_E_KEYMISSING 0x80040152
#define REGDB_E_INVALIVALUE 0x80040153
#define REGDB_E_CLASSNOTREG 0x80040154 #define REGDB_E_CLASSNOTREG 0x80040154
#define REGDB_E_IIDNOTREG 0x80040155
#define INPLACE_E_NOTUNDOABLE 0x800401A0 #define INPLACE_E_NOTUNDOABLE 0x800401A0
#define INPLACE_E_NOTOOLSPACE 0x800401A1 #define INPLACE_E_NOTOOLSPACE 0x800401A1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment