diff options
author | steven_carr <steven_carr> | 2006-06-05 18:50:45 +0000 |
---|---|---|
committer | steven_carr <steven_carr> | 2006-06-05 18:50:45 +0000 |
commit | a60ee2ee9f73d21c4407136d7a2878a34be2f7ed (patch) | |
tree | efa990d9cc4983be6d2a71b4b9119bcca9817b2e /libvncserver | |
parent | 6bd995ec77d68f21d58d72e286ffaac080978930 (diff) | |
download | libtdevnc-a60ee2ee9f73d21c4407136d7a2878a34be2f7ed.tar.gz libtdevnc-a60ee2ee9f73d21c4407136d7a2878a34be2f7ed.zip |
RFB 3.8 clients are well informed
Diffstat (limited to 'libvncserver')
-rwxr-xr-x | libvncserver/auth.c | 8 | ||||
-rw-r--r-- | libvncserver/rfbserver.c | 31 |
2 files changed, 30 insertions, 9 deletions
diff --git a/libvncserver/auth.c b/libvncserver/auth.c index 642cca6..b8fbad6 100755 --- a/libvncserver/auth.c +++ b/libvncserver/auth.c @@ -29,6 +29,10 @@ #include <rfb/rfb.h> +/* RFB 3.8 clients are well informed */ +void rfbClientSendString(rfbClientPtr cl, char *reason); + + /* * Handle security types */ @@ -207,7 +211,7 @@ rfbSendSecurityTypeList(rfbClientPtr cl, int primaryType) /* The execution should never reach here */ char* reason = "No authentication mode is registered!"; - rfbClientConnFailed(cl, reason); + rfbClientSendString(cl, reason); return; } @@ -352,7 +356,7 @@ rfbAuthProcessClientMessage(rfbClientPtr cl) } /* support RFB 3.8 clients, they expect a reason *why* it was disconnected */ if (cl->protocolMinorVersion > 7) { - rfbClientConnFailed(cl, "password check failed!"); + rfbClientSendString(cl, "password check failed!"); } else rfbCloseClient(cl); diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 57ba5d9..ae4877b 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -587,7 +587,6 @@ rfbProcessClientProtocolVersion(rfbClientPtr cl) { rfbProtocolVersionMsg pv; int n, major_, minor_; - char failureReason[256]; if ((n = rfbReadExact(cl, pv, sz_rfbProtocolVersionMsg)) <= 0) { if (n == 0) @@ -612,14 +611,10 @@ rfbProcessClientProtocolVersion(rfbClientPtr cl) rfbLog("Client Protocol Version %d.%d\n", major_, minor_); if (major_ != rfbProtocolMajorVersion) { - /* Major version mismatch - send a ConnFailed message */ - - rfbErr("Major version mismatch\n"); - sprintf(failureReason, - "RFB protocol version mismatch - server %d.%d, client %d.%d", + rfbErr("RFB protocol version mismatch - server %d.%d, client %d.%d", cl->screen->protocolMajorVersion, cl->screen->protocolMinorVersion, major_,minor_); - rfbClientConnFailed(cl, failureReason); + rfbCloseClient(cl); return; } @@ -641,6 +636,25 @@ rfbProcessClientProtocolVersion(rfbClientPtr cl) } +void +rfbClientSendString(rfbClientPtr cl, char *reason) +{ + char *buf; + int len = strlen(reason); + + rfbLog("rfbClientSendString(\"%s\")\n", reason); + + buf = (char *)malloc(4 + len); + ((uint32_t *)buf)[0] = Swap32IfLE(len); + memcpy(buf + 4, reason, len); + + if (rfbWriteExact(cl, buf, 4 + len) < 0) + rfbLogPerror("rfbClientSendString: write"); + free(buf); + + rfbCloseClient(cl); +} + /* * rfbClientConnFailed is called when a client connection has failed either * because it talks the wrong protocol or it has failed authentication. @@ -653,6 +667,8 @@ rfbClientConnFailed(rfbClientPtr cl, char *buf; int len = strlen(reason); + rfbLog("rfbClientConnFailed(\"%s\")\n", reason); + buf = (char *)malloc(8 + len); ((uint32_t *)buf)[0] = Swap32IfLE(rfbConnFailed); ((uint32_t *)buf)[1] = Swap32IfLE(len); @@ -661,6 +677,7 @@ rfbClientConnFailed(rfbClientPtr cl, if (rfbWriteExact(cl, buf, 8 + len) < 0) rfbLogPerror("rfbClientConnFailed: write"); free(buf); + rfbCloseClient(cl); } |