CVS: winex/dlls/rpcrt4 cpsf.c,1.4,1.5
[email protected] 1 Aug 2007 12:24:48 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/rpcrt4 cpsf.c,1.4,1.5Update of /var/lib/cvsd/cvsroot/winex/dlls/rpcrt4
In directory agravaine:/tmp/cvs-serv28226/dlls/rpcrt4
Modified Files:
cpsf.c
Log Message:
- fixed GetModuleFileNameA() to properly return a truncated filename error code. GetModuleFileNameW() just calls GetModuleFileNameA(), so its error codes should be updated as well.
- fixed all the calls to GetModuleFileNameA/W() to check for small buffer and bad module errors. Currently small buffer errors are just reported and are allowed to proceed with either an empty string or truncated string for the filename. In the case of an error retrieving the module filename (error == 0), the calling function reports the error and returns immediately.
Index: cpsf.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/rpcrt4/cpsf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cpsf.c 11 May 2003 11:04:55 -0000 1.4
+++ cpsf.c 1 Aug 2007 12:24:46 -0000 1.5
@@ -146,6 +146,7 @@
LPSTR clsid;
char keyname[120], module[120];
HKEY key, subkey;
+ DWORD error;
TRACE("(%x,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
UuidToStringA((UUID*)pclsid, &clsid);
@@ -181,7 +182,18 @@
/* register clsid to point to module */
snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid);
- GetModuleFileNameA(hDll, module, sizeof(module));
+ error = GetModuleFileNameA(hDll, module, sizeof(module));
+
+ if (error == sizeof(module))
+ ERR("the buffer for GetModuleFileNameA() is too small!\n");
+
+ else if (error == 0){
+ ERR("could not retrieve the module filename for 0x%lx\n", hDll);
+
+ return E_FAIL;
+ }
+
+
TRACE("registering CLSID %s => %s\n", clsid, module);
if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0,
KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
@@ -207,6 +219,7 @@
{
LPSTR clsid;
char keyname[120], module[120];
+ DWORD error;
TRACE("(%x,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
UuidToStringA((UUID*)pclsid, &clsid);
@@ -231,7 +244,18 @@
/* unregister clsid */
snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid);
- GetModuleFileNameA(hDll, module, sizeof(module));
+ error = GetModuleFileNameA(hDll, module, sizeof(module));
+
+ if (error == sizeof(module))
+ ERR("the buffer for GetModuleFileNameA() is too small!\n");
+
+ else if (error == 0){
+ ERR("could not retrieve the module filename for 0x%lx\n", hDll);
+
+ return E_FAIL;
+ }
+
+
TRACE("unregistering CLSID %s <= %s\n", clsid, module);
RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname);