CVS: winex/dlls/advpack reg.c,1.1,1.2
[email protected] 1 Aug 2007 12:22:47 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/advpack reg.c,1.1,1.2Update of /var/lib/cvsd/cvsroot/winex/dlls/advpack
In directory agravaine:/tmp/cvs-serv27258/dlls/advpack
Modified Files:
reg.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: reg.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/advpack/reg.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- reg.c 25 Aug 2005 20:32:31 -0000 1.1
+++ reg.c 1 Aug 2007 12:22:45 -0000 1.2
@@ -107,6 +107,7 @@
WCHAR tmp_ini_path[MAX_PATH];
WCHAR mod_path[MAX_PATH + 2], sys_mod_path[MAX_PATH + 2], sys_root[MAX_PATH];
HINF hinf;
+ DWORD len;
WCHAR quote[] = {'\"',0};
UNICODE_STRING section;
@@ -121,7 +122,18 @@
/* Write a couple of pre-defined strings */
mod_path[0] = '\"';
- GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path)/sizeof(WCHAR) - 2);
+ len = GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path)/sizeof(WCHAR) - 2);
+
+ if (len == sizeof(mod_path)/sizeof(WCHAR) - 2)
+ ERR("the buffer for GetModuleFileNameW() is too small!\n");
+
+ else if (len == 0){
+ ERR("could not retrieve the filename of the module '0x%lx'\n", hm);
+
+ return E_FAIL;
+ }
+
+
strcatW(mod_path, quote);
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, tmp_ini_path);