aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-17 19:09:26 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commitef8c84eb752e1b59ef824cedeb156b2d64fefe37 (patch)
tree4ddde34cbd29da534fb8f43fd505aca80a96a3f1
parent803a6ae087331d2701daf608128c2e5ff1d596a7 (diff)
downloadtigervnc-ef8c84eb752e1b59ef824cedeb156b2d64fefe37.tar.gz
tigervnc-ef8c84eb752e1b59ef824cedeb156b2d64fefe37.zip
Remove trailing slash from getvnchomedir()
It should return a path to the directory itself, just like its sister function getuserhomedir().
-rw-r--r--common/os/os.cxx6
-rw-r--r--common/rfb/CSecurityTLS.cxx6
-rw-r--r--unix/vncpasswd/vncpasswd.cxx4
-rw-r--r--vncviewer/ServerDialog.cxx4
-rw-r--r--vncviewer/parameters.cxx4
5 files changed, 12 insertions, 12 deletions
diff --git a/common/os/os.cxx b/common/os/os.cxx
index 5492c55e..2dfabc46 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 a8ef779d..c702280d 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 66c82144..4d91fda7 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 a6b0e80f..db39cd59 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 03f2b145..ff5589d2 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);
}