From 2f9836d81a60913c4b632e8fa7148390e22bcefa Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Mon, 14 Sep 2009 12:54:17 +0800 Subject: [PATCH] Fix bug for logging unsupported security types Signed-off-by: Vic Lee --- libvncclient/rfbproto.c | 32 ++++++++++++++++++++++++++------ 1 file 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=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 {