summaryrefslogtreecommitdiffstats
path: root/libvncclient/rfbproto.c
diff options
context:
space:
mode:
authorVic Lee <llyzs@163.com>2009-09-14 12:54:17 +0800
committerJohannes Schindelin <johannes.schindelin@gmx.de>2009-09-27 14:20:53 +0200
commit2f9836d81a60913c4b632e8fa7148390e22bcefa (patch)
treefdb9f3d8a9d1379d7cfd27af726bed1d48bc0764 /libvncclient/rfbproto.c
parent4e1aba74e6b485c39c4522f1f65c114b88b61636 (diff)
downloadlibtdevnc-2f9836d81a60913c4b632e8fa7148390e22bcefa.tar.gz
libtdevnc-2f9836d81a60913c4b632e8fa7148390e22bcefa.zip
Fix bug for logging unsupported security types
Signed-off-by: Vic Lee <llyzs@163.com>
Diffstat (limited to 'libvncclient/rfbproto.c')
-rw-r--r--libvncclient/rfbproto.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
index c73593f..f9386ed 100644
--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -531,7 +531,8 @@ InitialiseRFBConnection(rfbClient* client)
uint8_t count=0;
uint8_t loop=0;
uint8_t flag=0;
- uint8_t tAuth=0;
+ uint8_t tAuth[256];
+ char buf1[500],buf2[10];
if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE;
@@ -549,23 +550,42 @@ InitialiseRFBConnection(rfbClient* client)
free(reason);
return FALSE;
}
+ if (count>sizeof(tAuth))
+ {
+ rfbClientLog("%d security types are too many; maximum is %d\n", count, sizeof(tAuth));
+ return FALSE;
+ }
rfbClientLog("We have %d security types to read\n", count);
+ authScheme=0;
/* now, we have a list of available security types to read ( uint8_t[] ) */
for (loop=0;loop<count;loop++)
{
- if (!ReadFromRFBServer(client, (char *)&tAuth, 1)) return FALSE;
- rfbClientLog("%d) Received security type %d\n", loop, tAuth);
- if ((flag==0) && ((tAuth==rfbVncAuth) || (tAuth==rfbNoAuth)))
+ if (!ReadFromRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;
+ rfbClientLog("%d) Received security type %d\n", loop, tAuth[loop]);
+ if ((flag==0) && ((tAuth[loop]==rfbVncAuth) || (tAuth[loop]==rfbNoAuth)))
{
flag++;
- authScheme=tAuth;
+ authScheme=tAuth[loop];
rfbClientLog("Selecting security type %d (%d/%d in the list)\n", authScheme, loop, count);
/* send back a single byte indicating which security type to use */
- if (!WriteToRFBServer(client, (char *)&tAuth, 1)) return FALSE;
+ if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;
}
}
+ if (authScheme==0)
+ {
+ memset(buf1, 0, sizeof(buf1));
+ for (loop=0;loop<count;loop++)
+ {
+ if (strlen(buf1)>=sizeof(buf1)-1) break;
+ snprintf(buf2, sizeof(buf2), (loop>0 ? ", %d" : "%d"), (int)tAuth[loop]);
+ strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1);
+ }
+ rfbClientLog("Unknown authentication scheme from VNC server: %s\n",
+ buf1);
+ return FALSE;
+ }
}
else
{