Better string handling of default server name
We might not get one from the default configuration (we might not have
a default configuration at all), so make things more robust.
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 6c0c738..f076565 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -519,11 +519,13 @@
Configuration::enableViewerParams();
/* Load the default parameter settings */
- char defaultServerName[VNCSERVERNAMELEN];
+ char defaultServerName[VNCSERVERNAMELEN] = "";
try {
- strncpy(defaultServerName, loadViewerParameters(NULL), VNCSERVERNAMELEN);
+ const char* configServerName;
+ configServerName = loadViewerParameters(NULL);
+ if (configServerName != NULL)
+ strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN);
} catch (rfb::Exception& e) {
- strcpy(defaultServerName, "");
vlog.error("%s", e.str());
if (alertOnFatalError)
fl_alert("%s", e.str());