T7B: Installer for WinNT
Larry Tremblay
lrt at nortelnetworks.com
Thu Oct 14 15:16:45 UTC 1999
If an error occurs in the BIND installer on WinNT, it may crash due to a
buffer overrun while formatting the error message - NT error messages can be
verbose.
There's also a memory leak in GetErrMsg().
Here's a patch.
Cheers!
L
--------------------------
--- BINDInstallDlg.orig.cpp Wed Oct 13 13:32:02 1999
+++ BINDInstallDlg.cpp Wed Oct 13 17:02:01 1999
@@ -889,10 +889,10 @@
{
CString format;
va_list va;
- char buf[128];
+ char buf[BUFSIZ];
format.LoadString(id);
- memset(buf, 0, 128);
+ memset(buf, 0, BUFSIZ);
va_start(va, id);
vsprintf(buf, format, va);
@@ -905,10 +905,10 @@
{
CString format;
va_list va;
- char buf[128];
+ char buf[BUFSIZ];
format.LoadString(id);
- memset(buf, 0, 128);
+ memset(buf, 0, BUFSIZ);
va_start(va, type);
vsprintf(buf, format, va);
@@ -922,13 +922,16 @@
*/
CString CBINDInstallDlg::GetErrMessage()
{
- static LPVOID msgBuf;
+ LPVOID msgBuf;
+ static char buf[BUFSIZ];
+
DWORD len = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &msgBuf, 0, NULL );
- LPTSTR str = (LPTSTR)msgBuf;
+ strcpy(buf, (LPTSTR)msgBuf);
+ LocalFree(msgBuf);
/* Strip off the period and the \n */
- str[len - 3] = 0;
- return(str);
+ buf[len - 3] = 0;
+ return(buf);
}
More information about the bind-workers
mailing list