diff --git a/common/os/os.cxx b/common/os/os.cxx index 5492c55e5e990ff2c291240f415355e83996f895..2dfabc46e0ad3b5047585d7ae8a5dbe1af68b6d4 100644 --- a/common/os/os.cxx +++ b/common/os/os.cxx @@ -66,7 +66,7 @@ static const char* gethomedir(bool userDir) if (userDir) return homedir; - snprintf(dir, sizeof(dir), "%s/.vnc/", homedir); + snprintf(dir, sizeof(dir), "%s/.vnc", homedir); return dir; #else @@ -81,10 +81,10 @@ static const char* gethomedir(bool userDir) if (userDir) return dir; - if (strlen(dir) + strlen("\\vnc\\") >= sizeof(dir)) + if (strlen(dir) + strlen("\\vnc") >= sizeof(dir)) return NULL; - strcat(dir, "\\vnc\\"); + strcat(dir, "\\vnc"); return dir; #endif diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index a8ef779d4653065e0e45a101ea725794a215537e..c702280dcb7d115f582ad82397c5b545b15b9433 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -82,7 +82,7 @@ static const char* homedirfn(const char* fn) if (homedir == NULL) return ""; - snprintf(full_path, sizeof(full_path), "%s%s", homedir, fn); + snprintf(full_path, sizeof(full_path), "%s/%s", homedir, fn); return full_path; } @@ -395,8 +395,8 @@ void CSecurityTLS::checkSession() "path for known hosts storage"); } - CharArray dbPath(strlen(homeDir) + 16 + 1); - sprintf(dbPath.buf, "%sx509_known_hosts", homeDir); + CharArray dbPath(strlen(homeDir) + strlen("/x509_known_hosts") + 1); + sprintf(dbPath.buf, "%s/x509_known_hosts", homeDir); err = gnutls_verify_stored_pubkey(dbPath.buf, NULL, client->getServerName(), NULL, diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx index 66c82144a8a3be405b54dd6723e917eb9a15774b..4d91fda7cfc848287e9dff0355ea32aa0a2482fe 100644 --- a/unix/vncpasswd/vncpasswd.cxx +++ b/unix/vncpasswd/vncpasswd.cxx @@ -152,8 +152,8 @@ int main(int argc, char** argv) exit(1); } mkdir(homeDir, 0777); - fname = new char[strlen(homeDir) + 7]; - sprintf(fname, "%spasswd", homeDir); + fname = new char[strlen(homeDir) + strlen("/passwd") + 1]; + sprintf(fname, "%s/passwd", homeDir); } while (true) { diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index a6b0e80f89ce42554b165618ac3fc935bebeb3d9..db39cd59e38a5ba3b101debdf7f1e46389f708a7 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -320,7 +320,7 @@ void ServerDialog::loadServerHistory() throw Exception(_("Could not obtain the home directory path")); char filepath[PATH_MAX]; - snprintf(filepath, sizeof(filepath), "%s%s", homeDir, SERVER_HISTORY); + snprintf(filepath, sizeof(filepath), "%s/%s", homeDir, SERVER_HISTORY); /* Read server history from file */ FILE* f = fopen(filepath, "r"); @@ -386,7 +386,7 @@ void ServerDialog::saveServerHistory() throw Exception(_("Could not obtain the home directory path")); char filepath[PATH_MAX]; - snprintf(filepath, sizeof(filepath), "%s%s", homeDir, SERVER_HISTORY); + snprintf(filepath, sizeof(filepath), "%s/%s", homeDir, SERVER_HISTORY); /* Write server history to file */ FILE* f = fopen(filepath, "w+"); diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 03f2b14507053dccb6e8d9e61ade8889e8950ba5..ff5589d24b1ed9911ef9311dfcb789468dba5752 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -633,7 +633,7 @@ void saveViewerParameters(const char *filename, const char *servername) { if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); - snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir); + snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", homeDir); } else { snprintf(filepath, sizeof(filepath), "%s", filename); } @@ -737,7 +737,7 @@ char* loadViewerParameters(const char *filename) { if (homeDir == NULL) throw Exception(_("Could not obtain the home directory path")); - snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir); + snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", homeDir); } else { snprintf(filepath, sizeof(filepath), "%s", filename); }