Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Single click bug during VNC encoding negotiation

Single Click discussions / bugs
Post Reply
drazel
Posts: 4
Joined: 2008-02-11 16:03
Location: Paris
Contact:

Single click bug during VNC encoding negotiation

Post by drazel »

Hello !

we are using a custom SC server with the javaViewer and we found what seems to be a bug in the encoding negotiation.

When asked for tight encoding for example, SC will return ZRLE, but the javaViewer does not support ZRLE (it does support Tight though)
Then when asking for Tight, we get ZRLE and it does not work at all...

What we did is quite simple, we just commented the unused cases in the switch, that way if an unknown encoding is requested, it returns FALSE and continues according to the VNC protocol

here is the corrected function we are using. The negociation should now be correct in every case.
Could this modification be included in a future release?

in vncencodemgr.h

Code: Select all

inline BOOL
vncEncodeMgr::SetEncoding(CARD32 encoding,BOOL reinitialize)
{
	if (reinitialize)
	{
		encoding=m_encoding;
		m_buffer->CheckBuffer();
	}
	else m_encoding=encoding;

	// Delete the old encoder
	if (m_encoder != NULL)
	{
		
		if (m_encoder != zrleEncoder)
			delete m_encoder;
		m_encoder = NULL;
		
	}
	// Returns FALSE if the desired encoding cannot be used
	switch(encoding)
	{

	case rfbEncodingRaw:

		vnclog.Print(LL_INTINFO, VNCLOG("raw encoder requested\n"));

		// Create a RAW encoder
		m_encoder = new vncEncoder;
		if (m_encoder == NULL)
			return FALSE;
		break;

	//Michael fix : do not give ZRLE (or else) if we ask for Tight (or else)
	/* ZRLE default*/
	//case rfbEncodingTight:	
	//case rfbEncodingZlib:
	//case rfbEncodingZlibHex:
	/* Hextile default*/
	//case rfbEncodingUltra:
	//case rfbEncodingRRE:
	//case rfbEncodingCoRRE:
	case rfbEncodingHextile:

		vnclog.Print(LL_INTINFO, VNCLOG("Hextile encoder requested\n"));

		// Create a CoRRE encoder
		m_encoder = new vncEncodeHexT;
		if (m_encoder == NULL)
			return FALSE;
		break;
	
	case rfbEncodingZRLE:
		vnclog.Print(LL_INTINFO, VNCLOG("ZRLE encoder requested\n"));
		if (!zrleEncoder)
			zrleEncoder = new vncEncodeZRLE;
		m_encoder = zrleEncoder;
		break;
		

	default:
		// An unknown encoding was specified
		vnclog.Print(LL_INTERR, VNCLOG("unknown encoder requested\n"));

		return FALSE;
	}

	// Initialise it and give it the pixel format
	m_encoder->Init();
	m_encoder->SetLocalFormat(
			m_scrinfo.format,
			m_scrinfo.framebufferWidth,
			m_scrinfo.framebufferHeight);
	if (m_clientfmtset)
		if (!m_encoder->SetRemoteFormat(m_clientformat))
		{
			vnclog.Print(LL_INTERR, VNCLOG("client pixel format is not supported\n"));

			return FALSE;
		}

	if (reinitialize)
	{
		if (m_encoder != NULL)
		{
			m_encoder->EnableXCursor(m_use_xcursor);
			m_encoder->EnableRichCursor(m_use_richcursor);
			m_encoder->SetCompressLevel(m_compresslevel);
			m_encoder->SetQualityLevel(m_qualitylevel);
			m_encoder->EnableLastRect(m_use_lastrect);
		}

	}
		m_buffer->ClearCache();
		m_buffer->ClearBack();
		m_encoder->SetSWOffset(m_SWOffsetx,m_SWOffsety);
	// Check that the client buffer is compatible
	return CheckBuffer();
}
------
WizHelp : http://www.wizhelp.com
Screen Sharing and Remote Control in 1 click
redge
1000
1000
Posts: 6797
Joined: 2004-07-03 17:05
Location: Switzerland - Geneva

Re: Single click bug during VNC encoding negotiation

Post by redge »

is this happen only to SC or also ultravnc server 1.0.4 rc16 ?
if uvnc 104 have same bug, i will report your code to the good place for fix.
UltraVNC 1.0.9.6.1 (built 20110518)
OS Win: xp home + vista business + 7 home
only experienced user, not developer
drazel
Posts: 4
Joined: 2008-02-11 16:03
Location: Paris
Contact:

Re: Single click bug during VNC encoding negotiation

Post by drazel »

Hi redge

It seems that the bug is only in SC.
It has not been tested with 1.0.4 rc16 but I took a look at the code and everything seems OK here.
------
WizHelp : http://www.wizhelp.com
Screen Sharing and Remote Control in 1 click
Post Reply