diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-15 14:41:47 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | d608a30d576ed74f7dc7374c1f00d2303fee27f6 (patch) | |
tree | a6637dee5800ee1f9af6331d3df02d84afe45d9a /win | |
parent | ef8c84eb752e1b59ef824cedeb156b2d64fefe37 (diff) | |
download | tigervnc-d608a30d576ed74f7dc7374c1f00d2303fee27f6.tar.gz tigervnc-d608a30d576ed74f7dc7374c1f00d2303fee27f6.zip |
Use fixed size character buffer
We know the needed space here, so let's keep it simple with a constant
size string buffer.
Diffstat (limited to 'win')
-rw-r--r-- | win/rfb_win32/ComputerName.h | 6 | ||||
-rw-r--r-- | win/rfb_win32/ModuleFileName.h | 7 | ||||
-rw-r--r-- | win/vncconfig/Legacy.cxx | 20 |
3 files changed, 16 insertions, 17 deletions
diff --git a/win/rfb_win32/ComputerName.h b/win/rfb_win32/ComputerName.h index 345ff0d7..e7064d5b 100644 --- a/win/rfb_win32/ComputerName.h +++ b/win/rfb_win32/ComputerName.h @@ -20,18 +20,18 @@ #define __RFB_WIN32_COMPUTERNAME_H__ #include <windows.h> -#include <rfb/util.h> namespace rfb { namespace win32 { // Get the computer name - struct ComputerName : CharArray { - ComputerName() : CharArray(MAX_COMPUTERNAME_LENGTH+1) { + struct ComputerName { + ComputerName() { ULONG namelength = MAX_COMPUTERNAME_LENGTH+1; if (!GetComputerName(buf, &namelength)) strcpy(buf, ""); } + char buf[MAX_COMPUTERNAME_LENGTH+1]; }; }; diff --git a/win/rfb_win32/ModuleFileName.h b/win/rfb_win32/ModuleFileName.h index 02a34f1a..9a06f50d 100644 --- a/win/rfb_win32/ModuleFileName.h +++ b/win/rfb_win32/ModuleFileName.h @@ -21,18 +21,17 @@ #include <windows.h> -#include <rfb/util.h> - namespace rfb { namespace win32 { - struct ModuleFileName : public CharArray { - ModuleFileName(HMODULE module=0) : CharArray(MAX_PATH) { + struct ModuleFileName { + ModuleFileName(HMODULE module=0) { if (!module) module = GetModuleHandle(0); if (!GetModuleFileName(module, buf, MAX_PATH)) buf[0] = 0; } + char buf[MAX_PATH]; }; }; diff --git a/win/vncconfig/Legacy.cxx b/win/vncconfig/Legacy.cxx index b428fd2a..e5433691 100644 --- a/win/vncconfig/Legacy.cxx +++ b/win/vncconfig/Legacy.cxx @@ -78,9 +78,9 @@ void LegacyPage::LoadPrefs() rfb::strSplit(tmp.buf, ':', &first.buf, &tmp.buf); if (strlen(first.buf)) { int bits = 0; - CharArray pattern(1+4*4+4); - pattern.buf[0] = first.buf[0]; - pattern.buf[1] = 0; + char pattern[1+4*4+4]; + pattern[0] = first.buf[0]; + pattern[1] = 0; // Split the pattern into IP address parts and process rfb::CharArray address; @@ -89,11 +89,11 @@ void LegacyPage::LoadPrefs() rfb::CharArray part; rfb::strSplit(address.buf, '.', &part.buf, &address.buf); if (bits) - strcat(pattern.buf, "."); + strcat(pattern, "."); if (strlen(part.buf) > 3) throw rdr::Exception("Invalid IP address part"); if (strlen(part.buf) > 0) { - strcat(pattern.buf, part.buf); + strcat(pattern, part.buf); bits += 8; } } @@ -101,20 +101,20 @@ void LegacyPage::LoadPrefs() // Pad out the address specification if required int addrBits = bits; while (addrBits < 32) { - if (addrBits) strcat(pattern.buf, "."); - strcat(pattern.buf, "0"); + if (addrBits) strcat(pattern, "."); + strcat(pattern, "0"); addrBits += 8; } // Append the number of bits to match char buf[4]; sprintf(buf, "/%d", bits); - strcat(pattern.buf, buf); + strcat(pattern, buf); // Append this pattern to the Hosts value - int length = strlen(newHosts.buf) + strlen(pattern.buf) + 2; + int length = strlen(newHosts.buf) + strlen(pattern) + 2; CharArray tmpHosts(length); - strcpy(tmpHosts.buf, pattern.buf); + strcpy(tmpHosts.buf, pattern); if (strlen(newHosts.buf)) { strcat(tmpHosts.buf, ","); strcat(tmpHosts.buf, newHosts.buf); |