From 5755630cda00225e855a3b6422e36f8402b071d8 Mon Sep 17 00:00:00 2001 From: Tim Jansen Date: Sat, 5 Jan 2002 03:40:06 +0000 Subject: [PATCH] Many rfblib improvements svn path=/trunk/kdenetwork/krfb/; revision=129944 --- ChangeLog | 13 ++++++++++++- TODO | 3 ++- krfb/XUpdateScanner.cc | 7 +++---- krfb/XUpdateScanner.h | 4 ++-- krfb/configuration.cc | 2 +- krfb/rfbconnection.cc | 12 +++++------- krfb/rfbconnection.h | 3 +-- krfb/rfbcontroller.cc | 16 ++++++++++------ 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59658619..274d9935 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,17 @@ +2002-01-05 Tim Jansen + + * krfb/rfbcontroller.cc: fixed crash after client disconnect while + krfb was writing + + * lib/rfbServer.cc: fixed some bugs, avoid endlessly collecting + data if client doesn't take them, check input from client + 2002-01-04 Tim Jansen - * lib/: moved lib directory from krfb/lib to lib + * lib/rfbServer.cc: use /dev/urandom for authentication challenge + if available + + * moved rfb lib directory from krfb/lib to lib 2002-01-03 Tim Jansen diff --git a/TODO b/TODO index c8d20351..a06e7f73 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,9 @@ Todo: - i18n - docs +- knotify - kcontrol module? -- encrypted connections (ssh, OpenSSL?) +- encrypted connections: http://web.mit.edu/thouis/vnc/ - TightVNC extensions - do something against potential denial-of-service attacks by repeatedly trying to connect to users until they agree. Maybe a message box diff --git a/krfb/XUpdateScanner.cc b/krfb/XUpdateScanner.cc index 53bbd648..43771eed 100644 --- a/krfb/XUpdateScanner.cc +++ b/krfb/XUpdateScanner.cc @@ -52,8 +52,8 @@ XUpdateScanner::XUpdateScanner(Display *_dpy, dpy(_dpy), window(_window), fb(_fb), - tileWidth(32), - tileHeight(32), + tileWidth(_tileWidth), + tileHeight(_tileHeight), blockWidth(_blockWidth), blockHeight(_blockHeight), count (0), @@ -160,8 +160,7 @@ void XUpdateScanner::checkTile(int x, int y, list &hintList) } } -void XUpdateScanner::searchUpdates(list &hintList, - bool showMousePointer) +void XUpdateScanner::searchUpdates(list &hintList) { count %= 32; unsigned int i; diff --git a/krfb/XUpdateScanner.h b/krfb/XUpdateScanner.h index 7b1fd4be..452e7829 100644 --- a/krfb/XUpdateScanner.h +++ b/krfb/XUpdateScanner.h @@ -44,7 +44,7 @@ class XUpdateScanner ~XUpdateScanner(); void checkTile( int x, int y, list< Hint > &hintList ); - void searchUpdates( list< Hint > &hintList, bool showMouse ); + void searchUpdates( list< Hint > &hintList); Display *dpy; @@ -66,4 +66,4 @@ class XUpdateScanner } // namespace rfb -#endif _hexonet_rfb_XUpdateScanner_h_ +#endif // _hexonet_rfb_XUpdateScanner_h_ diff --git a/krfb/configuration.cc b/krfb/configuration.cc index 544557f6..3e9c7d27 100644 --- a/krfb/configuration.cc +++ b/krfb/configuration.cc @@ -47,9 +47,9 @@ Configuration::Configuration(bool oneConnection, bool askOnConnect, bool allowDesktopControl, QString password, int port) : preconfiguredFlag(true), - oneConnectionFlag(oneConnection), askOnConnectFlag(askOnConnect), allowDesktopControlFlag(allowDesktopControl), + oneConnectionFlag(oneConnection), passwordString(password) { if ((port >= 5900) && (port < 6000)) diff --git a/krfb/rfbconnection.cc b/krfb/rfbconnection.cc index b89b8039..600679ff 100644 --- a/krfb/rfbconnection.cc +++ b/krfb/rfbconnection.cc @@ -35,14 +35,12 @@ static XTestDisabler disabler; RFBConnection::RFBConnection(Display *_dpy, int _fd, const QString &cpassword, - bool _allowInput, - bool _showMousePointer) : + bool _allowInput) : Server(), - dpy(_dpy), fd(_fd), + buttonMask(0), allowInput(_allowInput), - showMousePointer(_showMousePointer), - buttonMask(0) + dpy(_dpy) { memcpy(password, "\0\0\0\0\0\0\0\0", 8); if (!cpassword.isNull()) @@ -59,7 +57,7 @@ RFBConnection::RFBConnection(Display *_dpy, InitBlocks(32, 32); - connection->send((unsigned char*) RFB_PROTOCOL_VERSION, 12); + sendFirstHandshake(connection); } RFBConnection::~RFBConnection() { @@ -164,7 +162,7 @@ void RFBConnection::scanUpdates() { list hintList; - scanner->searchUpdates(hintList, showMousePointer); + scanner->searchUpdates(hintList); list::iterator i; for (i = hintList.begin(); i != hintList.end(); i++) handleHint(*i); diff --git a/krfb/rfbconnection.h b/krfb/rfbconnection.h index 5f7fa866..2a7b2ccd 100644 --- a/krfb/rfbconnection.h +++ b/krfb/rfbconnection.h @@ -52,7 +52,7 @@ class RFBConnection : public QObject, public Server { public: RFBConnection(Display *dpy, int fd, const QString &cpassword, - bool allowInput, bool showMouse); + bool allowInput); ~RFBConnection(); virtual void handleKeyEvent(KeyEvent &keyEvent); virtual void handlePointerEvent(PointerEvent &pointerEvent); @@ -68,7 +68,6 @@ private: int fd; int buttonMask; bool allowInput; - bool showMousePointer; XUpdateScanner *scanner; diff --git a/krfb/rfbcontroller.cc b/krfb/rfbcontroller.cc index 62c1ae7a..36dc0bb5 100644 --- a/krfb/rfbcontroller.cc +++ b/krfb/rfbcontroller.cc @@ -102,6 +102,7 @@ void RFBController::accepted(KSocket *s) { if (socket) { kdWarning() << "refuse 2nd connection" << endl; + // TODO: send connection failed with reason delete s; return; } @@ -136,8 +137,7 @@ void RFBController::acceptConnection(bool allowDesktopControl) { s->enableWrite(true); connection = new RFBConnection(qt_xdisplay(), s->socket(), configuration->password(), - allowDesktopControl, - false); + allowDesktopControl); emit sessionEstablished(); } @@ -162,7 +162,8 @@ void RFBController::checkWriteBuffer() { } void RFBController::socketReadable() { - ASSERT(socket); + if ((!socket) || (!connection)) + return; int fd = socket->socket(); BufferedConnection *bc = connection->bufferedConnection; int count = read(fd, @@ -175,6 +176,7 @@ void RFBController::socketReadable() { KMessageBox::error(0, i18n("An error occurred while reading from the remote client. The connection will be terminated."), i18n("KRfb Error")); + return; } while (connection->currentState && bc->hasReceiverBufferData()) { connection->update(); @@ -188,8 +190,10 @@ void RFBController::socketReadable() { } void RFBController::socketWritable() { - ASSERT(socket); + if ((!socket) || (!connection)) + return; int fd = socket->socket(); + BufferedConnection *bc = connection->bufferedConnection; ASSERT((bc->senderBuffer.end - bc->senderBuffer.pos) > 0); int count = write(fd, @@ -197,13 +201,13 @@ void RFBController::socketWritable() { bc->senderBuffer.end - bc->senderBuffer.pos); if (count >= 0) { bc->senderBuffer.pos += count; + checkWriteBuffer(); } else { + closeSession(); KMessageBox::error(0, i18n("An error occurred while writing to the remote client. The connection will be terminated."), i18n("KRfb Error")); } - - checkWriteBuffer(); } void RFBController::closeSession() {