Browse Source

Make sure server name is always a valid string

Otherwise we can get crashes on NULL dereference. This should only
happen on reverse connections where we don't have a server address.
tags/v1.12.90
Pierre Ossman 2 years ago
parent
commit
7cba36627c
2 changed files with 9 additions and 2 deletions
  1. 8
    1
      common/rfb/CConnection.cxx
  2. 1
    1
      common/rfb/CConnection.h

+ 8
- 1
common/rfb/CConnection.cxx View File

@@ -52,7 +52,7 @@ CConnection::CConnection()
supportsDesktopResize(false), supportsLEDState(false),
is(0), os(0), reader_(0), writer_(0),
shared(false),
state_(RFBSTATE_UNINITIALISED),
state_(RFBSTATE_UNINITIALISED), serverName(strDup("")),
pendingPFChange(false), preferredEncoding(encodingTight),
compressLevel(2), qualityLevel(-1),
formatChange(false), encodingChange(false),
@@ -68,6 +68,13 @@ CConnection::~CConnection()
close();
}

void CConnection::setServerName(const char* name_)
{
if (name_ == NULL)
name_ = "";
serverName.replaceBuf(strDup(name_));
}

void CConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
{
is = is_;

+ 1
- 1
common/rfb/CConnection.h View File

@@ -48,7 +48,7 @@ namespace rfb {
// which we are connected. This might be the result of getPeerEndpoint on
// a TcpSocket, for example, or a host specified by DNS name & port.
// The serverName is used when verifying the Identity of a host (see RA2).
void setServerName(const char* name_) { serverName.replaceBuf(strDup(name_)); }
void setServerName(const char* name_);

// setStreams() sets the streams to be used for the connection. These must
// be set before initialiseProtocol() and processMsg() are called. The

Loading…
Cancel
Save