Don't require server name in config file
The user might just want to load a bunch of settings and not
initiate a connection.
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 16de6e3..51cce3d 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -540,6 +540,8 @@
char decodingBuffer[buffersize];
static char servername[sizeof(line)];
+ memset(servername, '\0', sizeof(servername));
+
// Load from the registry or a predefined file if no filename was specified.
if(filename == NULL) {
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index fabd665..e305d79 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -377,14 +377,11 @@
if (hasPathSeparator) {
try {
- strncpy(vncServerName, loadViewerParameters(vncServerName),
- VNCSERVERNAMELEN);
- if (vncServerName[0] == '\0') {
- vlog.error("Unable to load the server name from given file");
- if (alertOnFatalError)
- fl_alert("Unable to load the server name from given file");
- exit(EXIT_FAILURE);
- }
+ const char* newServerName;
+ newServerName = loadViewerParameters(vncServerName);
+ // This might be empty, but we still need to clear it so we
+ // don't try to connect to the filename
+ strncpy(vncServerName, newServerName, VNCSERVERNAMELEN);
} catch (rfb::Exception& e) {
vlog.error("%s", e.str());
if (alertOnFatalError)
@@ -510,11 +507,11 @@
Configuration::enableViewerParams();
/* Load the default parameter settings */
- const char* defaultServerName;
+ char defaultServerName[VNCSERVERNAMELEN];
try {
- defaultServerName = loadViewerParameters(NULL);
+ strncpy(defaultServerName, loadViewerParameters(NULL), VNCSERVERNAMELEN);
} catch (rfb::Exception& e) {
- defaultServerName = "";
+ strcpy(defaultServerName, "");
vlog.error("%s", e.str());
if (alertOnFatalError)
fl_alert("%s", e.str());