ref: 5a2ad90bec85dbfd5c5f6bb1b0ff88a73cfe1911
parent: c7db24fc26ae57be607887b20dc180a64a73fa3e
author: cinap_lenrek <[email protected]>
date: Wed May 4 22:11:00 EDT 2016
vncv: fix netmkvncaddr() netmkaddr() can return a the pointer to the host string if it is already a full dial string. but we assumed to get a copy and freed it before returning.
--- a/sys/src/cmd/vnc/vncv.c
+++ b/sys/src/cmd/vnc/vncv.c
@@ -43,14 +43,11 @@
}
char*
-netmkvncaddr(char *inserver)
+netmkvncaddr(char *server)
{
- char *p, portstr[NETPATHLEN], *server;
+ char *p, portstr[NETPATHLEN];
int port;
- server = strdup(inserver);
- assert(server != nil);
-
port = 5900;
if(tls)
port = 35729;
@@ -58,11 +55,8 @@
*p++ = '\0';
port += atoi(p);
}
-
snprint(portstr, sizeof portstr, "%d", port);
- p = netmkaddr(server, "tcp", portstr);
- free(server);
- return p;
+ return netmkaddr(server, "tcp", portstr);
}
void
@@ -82,7 +76,7 @@
main(int argc, char **argv)
{
int p, dfd, cfd, shared;
- char *keypattern, *addr, *label;
+ char *keypattern, *label;
Point d;
keypattern = nil;
@@ -116,11 +110,10 @@
if(argc != 1)
usage();
- addr = netmkvncaddr(argv[0]);
- serveraddr = argv[0];
- dfd = dial(addr, nil, nil, &cfd);
+ serveraddr = strdup(argv[0]);
+ dfd = dial(netmkvncaddr(argv[0]), nil, nil, &cfd);
if(dfd < 0)
- sysfatal("cannot dial %s: %r", addr);
+ sysfatal("cannot dial %s: %r", serveraddr);
if(tls){
TLSconn conn;