ref: d263134394105c35eefe3b115b4acf5941d8e899
parent: 43636dbb7f5dc5d116ae2773f68e3c828f72d4c2
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Aug 16 16:34:46 EDT 2018
vncv: handle [] enclosed literal ipv6 addresses in host
--- a/sys/src/cmd/vnc/auth.c
+++ b/sys/src/cmd/vnc/auth.c
@@ -53,7 +53,6 @@
char *reason;
uchar chal[VncChalLen];
ulong auth;
- char *p, *server;
if(keypattern == nil)
keypattern = "";
@@ -79,16 +78,10 @@
case AVncAuth:
vncrdbytes(v, chal, VncChalLen);
- server = strdup(serveraddr);
- p = strrchr(server, ':');
- if(p)
- *p = 0;
if(auth_respond(chal, VncChalLen, nil, 0, chal, VncChalLen, auth_getkey,
- "proto=vnc role=client server=%s %s", server, keypattern) != VncChalLen){
- free(server);
+ "proto=vnc role=client server=%s %s", serveraddr, keypattern) != VncChalLen){
return -1;
}
- free(server);
vncwrbytes(v, chal, VncChalLen);
vncflush(v);
--- a/sys/src/cmd/vnc/vncv.c
+++ b/sys/src/cmd/vnc/vncv.c
@@ -51,7 +51,9 @@
port = 5900;
if(tls)
port = 35729;
- if(p = strchr(server, ':')) {
+ if((p = strchr(server, ']')) == nil)
+ p = server;
+ if((p = strchr(p, ':')) != nil) {
*p++ = '\0';
port += atoi(p);
}
@@ -110,7 +112,7 @@
usage();
serveraddr = strdup(argv[0]);
- dfd = dial(netmkvncaddr(argv[0]), nil, nil, &cfd);
+ dfd = dial(netmkvncaddr(serveraddr), nil, nil, &cfd);
if(dfd < 0)
sysfatal("cannot dial %s: %r", serveraddr);
if(tls){
@@ -132,7 +134,7 @@
if(vncstart(vnc, shared) < 0)
sysfatal("init failure: %r");
- label = smprint("vnc %s", serveraddr);
+ label = smprint("vnc %s", argv[0]);
if(initdraw(0, 0, label) < 0)
sysfatal("initdraw: %r");
free(label);