From b9f7ffa424b93c40e58578d5adca289dba7e5400 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Mon, 10 Mar 2003 19:05:25 +0000 Subject: [PATCH] windows fixes svn path=/trunk/boinc/; revision=1038 --- client/win/hostinfo_win.cpp | 9 +++++---- client/win/win_util.cpp | 3 ++- client/win/wingui.cpp | 6 +++--- client/win/wingui_dialog.cpp | 3 ++- client/win/wingui_mainwindow.cpp | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/win/hostinfo_win.cpp b/client/win/hostinfo_win.cpp index df38ed086b..f2d0018d32 100755 --- a/client/win/hostinfo_win.cpp +++ b/client/win/hostinfo_win.cpp @@ -23,6 +23,7 @@ #include #include "client_types.h" #include "hostinfo.h" +#include "util.h" typedef BOOL (CALLBACK* FreeFn)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); @@ -133,7 +134,7 @@ int get_host_info(HOST_INFO& host) { Version, "%lu.%lu", OSVersionInfo.dwMajorVersion, OSVersionInfo.dwMinorVersion ); - strcpy( host.os_version, Version ); + safe_strncpy( host.os_version, Version, sizeof(host.os_version) ); SYSTEM_INFO SystemInfo; memset( &SystemInfo, NULL, sizeof( SystemInfo ) ); @@ -186,8 +187,8 @@ int get_host_info(HOST_INFO& host) { WSAStartup(wVersionRequested, &wsdata); // Get host name/ip info - get_local_domain_name(host.domain_name, 256); - get_local_ip_addr_str(host.ip_addr); + get_local_domain_name(host.domain_name, sizeof(host.domain_name)); + get_local_ip_addr_str(host.ip_addr, sizeof(host.ip_addr)); // Close the WinSock dll WSACleanup(); @@ -211,7 +212,7 @@ int get_host_info(HOST_INFO& host) { nameSize = sizeof(vendorName); retval = RegQueryValueEx(hKey, "VendorIdentifier", NULL, NULL, (LPBYTE)vendorName, &nameSize); if(retval == ERROR_SUCCESS) { - strcpy(host.p_vendor, vendorName); + safe_strncpy(host.p_vendor, vendorName, sizeof(host.p_vendor)); } } RegCloseKey(hKey); diff --git a/client/win/win_util.cpp b/client/win/win_util.cpp index 0e3c1f25e8..7739f5394e 100755 --- a/client/win/win_util.cpp +++ b/client/win/win_util.cpp @@ -1,5 +1,6 @@ #include #include "win_util.h" +#include "util.h" #define OS_UNKNOWN 0 #define OS_WIN95 1 @@ -75,7 +76,7 @@ int UtilGetRegKey(char *name, DWORD &keyval) DWORD value; HKEY boinc_key; - strcpy( str, "SOFTWARE\\BOINC\\" ); + safe_strncpy( str, "SOFTWARE\\BOINC\\", sizeof(str) ); strcat( str, name ); if ( OSVersion == OS_WIN95 ) { diff --git a/client/win/wingui.cpp b/client/win/wingui.cpp index 4a5e4f4b6d..07233b9aaf 100755 --- a/client/win/wingui.cpp +++ b/client/win/wingui.cpp @@ -27,12 +27,12 @@ void show_message(PROJECT* p, char* message, int priority) { if (p) { if (strcmp(p->project_name, "")) { - strcpy( proj_name, p->project_name ); + safe_strncpy( proj_name, p->project_name, sizeof(proj_name) ); } else { - strcpy( proj_name, p->master_url ); + safe_strncpy( proj_name, p->master_url, sizeof(proj_name) ); } } else { - strcpy( proj_name, "BOINC" ); + safe_strncpy( proj_name, "BOINC", sizeof(proj_name) ); } if(g_myWnd) { diff --git a/client/win/wingui_dialog.cpp b/client/win/wingui_dialog.cpp index e23d54aa2e..5ca61bb95b 100755 --- a/client/win/wingui_dialog.cpp +++ b/client/win/wingui_dialog.cpp @@ -462,7 +462,8 @@ void CProxyDialog::OnOK() } } GetDlgItemText(IDC_EDIT_HTTP_ADDR, strbuf); - strcpy(gstate.proxy_server_name, strbuf.GetBuffer(0)); + safe_strncpy(gstate.proxy_server_name, strbuf.GetBuffer(0), + sizeof(gstate.proxy_server_name)); GetDlgItemText(IDC_EDIT_HTTP_PORT, strbuf); gstate.proxy_server_port = atoi(strbuf.GetBuffer(0)); CDialog::OnOK(); diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 01c7f6ea04..e51e59ac45 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -515,11 +515,11 @@ void CMainWindow::SetStatusIcon(DWORD dwMessage) // if icon is in that state already, there is nothing to do if(dwMessage == m_nIconState) return; NOTIFYICONDATA icon_data; - icon_data.cbSize = sizeof(icon_data); + icon_data.cbSize = sizeof(NOTIFYICONDATA); icon_data.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; icon_data.hWnd = GetSafeHwnd(); icon_data.uID = STATUS_ICON_ID; - strcpy(icon_data.szTip, WND_TITLE); + safe_strncpy(icon_data.szTip, WND_TITLE, sizeof(icon_data.szTip)); icon_data.uCallbackMessage = STATUS_ICON_ID; if(dwMessage == ICON_OFF) { icon_data.hIcon = NULL;