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);
+ strncpy(vncServerName, newServerName, VNCSERVERNAMELEN-1);
+ vncServerName[VNCSERVERNAMELEN-1] = '\0';
} catch (rfb::Exception& e) {
vlog.error("%s", e.str());
if (alertOnFatalError)
try {
const char* configServerName;
configServerName = loadViewerParameters(NULL);
- if (configServerName != NULL)
- strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN);
+ if (configServerName != NULL) {
+ strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN-1);
+ defaultServerName[VNCSERVERNAMELEN-1] = '\0';
+ }
} catch (rfb::Exception& e) {
vlog.error("%s", e.str());
if (alertOnFatalError)