aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CSecurityTLS.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-13 11:14:21 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit5c1ac16776cd9f2a75e31086755e72186b3b3d41 (patch)
tree234a54c7f11c25ba59f8487118d13eb550c1cc64 /common/rfb/CSecurityTLS.cxx
parent1af2a56f7583b301890f8ea213f262782cc3c9f1 (diff)
downloadtigervnc-5c1ac16776cd9f2a75e31086755e72186b3b3d41.tar.gz
tigervnc-5c1ac16776cd9f2a75e31086755e72186b3b3d41.zip
Return static char buffer from some methods
This mimics how some system functions (like inet_ntop()) work, and avoids complexity around ownership of the returned string buffer. The downside is that the string must be consumed directly as it will be overwritten on the next call, but that is not an issue with the current usage.
Diffstat (limited to 'common/rfb/CSecurityTLS.cxx')
-rw-r--r--common/rfb/CSecurityTLS.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index aaf792d3..dd4a5282 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -76,15 +76,14 @@ static LogWriter vlog("TLS");
static const char* homedirfn(const char* fn)
{
static char full_path[PATH_MAX];
- char* homedir = NULL;
+ const char* homedir;
- if (getvnchomedir(&homedir) == -1)
+ homedir = getvnchomedir();
+ if (homedir == NULL)
return "";
snprintf(full_path, sizeof(full_path), "%s%s", homedir, fn);
- delete [] homedir;
-
return full_path;
}
@@ -310,7 +309,7 @@ void CSecurityTLS::checkSession()
unsigned int cert_list_size = 0;
int err;
- char *homeDir;
+ const char *homeDir;
gnutls_datum_t info;
size_t len;
@@ -390,15 +389,14 @@ void CSecurityTLS::checkSession()
/* Certificate is fine, except we don't know the issuer, so TOFU time */
- homeDir = NULL;
- if (getvnchomedir(&homeDir) == -1) {
+ homeDir = getvnchomedir();
+ if (homeDir == NULL) {
throw AuthFailureException("Could not obtain VNC home directory "
"path for known hosts storage");
}
CharArray dbPath(strlen(homeDir) + 16 + 1);
sprintf(dbPath.buf, "%sx509_known_hosts", homeDir);
- delete [] homeDir;
err = gnutls_verify_stored_pubkey(dbPath.buf, NULL,
client->getServerName(), NULL,