aboutsummaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Add stream avail() methodsPierre Ossman2020-05-2113-22/+38
| | | | | Makes it more readable to write code that needs to know how much data/space is available in a stream.
* Remove OutStream::skip()Pierre Ossman2020-05-212-9/+1
| | | | | It might leak data depending on what's in the buffer. Use pad() instead where blank space is needed.
* Remove unused stream methodsPierre Ossman2020-05-213-35/+1
| | | | | They were accidentally left unused in fbad8a9 so they haven't been used in some time.
* Throw more descriptive error on decode errorPierre Ossman2020-05-211-2/+7
| | | | We need to be able to tell this exception came from a decoder.
* Use proper constants for socket shutdown()Pierre Ossman2020-05-211-2/+5
| | | | For readability.
* Flush data on closePierre Ossman2020-05-211-0/+11
| | | | | There might be some final handshake data that is still stuck in the buffers, so make a best effort attempt at getting it to the client.
* Fix connection close logPierre Ossman2020-05-192-2/+4
| | | | | The socket is closed at this point so we have to rely on a cached value for the logging.
* Move auth failure delay to SConnectionPierre Ossman2020-05-194-46/+54
| | | | | It's a generic feature that is better handled as part of SConnection's state machine.
* Support calling methods from timersPierre Ossman2020-05-191-0/+15
| | | | | | We can't safely use the normal timers in base classes as we cannot guarantee that subclasses will call the base class' handleTimeout() properly if the subclass overrides it.
* Merge branch 'systemd' of https://github.com/CendioOssman/tigervncPierre Ossman2020-04-025-24/+6
|\
| * Make PAM mandatoryPierre Ossman2020-03-125-24/+6
| | | | | | | | | | It is present on all UNIX systems anyway, so let's simplify things. We will need it for more proper session startup anyway.
* | Include error code in getaddrinfo() exceptionsPierre Ossman2020-03-261-1/+10
| |
* | Avoid using insecure variable length arraysPierre Ossman2020-03-261-1/+2
| |
* | Merge branch 'unicode_translation' of https://github.com/CendioAlex/tigervncPierre Ossman2020-03-173-35/+38
|\ \ | |/ |/|
| * Throw GAIException() for getaddrinfo errorsAlex Tanskanen2020-03-173-8/+28
| | | | | | | | | | | | | | | | Created a new subclass of Exception called GAIException() that will handle error messages from getaddrinfo() instead of letting Exception() handle it. GAIException() will make use of gai_strerror() to map the error code to text. On Windows, gai_strerrorW() must be used if the text is encoded with UTF-8.
| * Fix typo in SocketException messageAlex Tanskanen2020-03-121-1/+1
| |
| * Make system error messeges in Windows 10 use UTF-8Alex Tanskanen2020-03-121-26/+9
| | | | | | | | | | | | The previous error messages did not support Unicode characters. This commit will use UTF-8 encoding to be able to display error messages in every language.
* | Fix error check for zlib callsPierre Ossman2020-02-272-3/+3
|/ | | | | There are multiple "okay" return values, not just Z_OK. Make sure we don't bail out needlessly.
* Use sys/time.h on Windows as wellPierre Ossman2020-01-161-4/+0
| | | | | | Modern MinGW seems to provide this, so simplify things a bit. This also side steps some of the issue of the windows.h/winsock2.h include ordering.
* Allow XK_Scroll_Lock when LED state isn't supportedPierre Ossman2020-01-031-9/+1
| | | | | Otherwise such clients cannot use Scroll Lock at all, and that is probably worse than any effects we might get from getting out of sync.
* Remove unneeded memory checksPierre Ossman2019-12-301-4/+0
| | | | new throws an exception on allocation errors rather than return NULL.
* Fix saving of bad server certificatesPierre Ossman2019-12-301-2/+3
| | | | | This check is completely backwards and it is currently unknown how this ever worked.
* Merge branch 'secfix' of https://github.com/CendioOssman/tigervncPierre Ossman2019-12-2041-338/+398
|\
| * Handle pixel formats with odd shift valuesPierre Ossman2019-11-151-0/+6
| | | | | | | | | | | | | | | | | | Our fast paths assume that each channel fits in to a separate byte. That means the shift needs to be a multiple of 8. Start actually checking this so that a client cannot trip us up and possibly cause incorrect code exection. Issue found by Pavel Cheremushkin from Kaspersky Lab.
| * Be defensive about overflows in stream objectsPierre Ossman2019-11-1513-48/+75
| | | | | | | | | | | | | | | | | | | | | | | | We use a lot of lengths given to us over the network, so be more paranoid about them causing an overflow as otherwise an attacker might trick us in to overwriting other memory. This primarily affects the client which often gets lengths from the server, but there are also some scenarios where the server might theoretically be vulnerable. Issue found by Pavel Cheremushkin from Kaspersky Lab.
| * Use size_t for lengths in stream objectsPierre Ossman2019-11-1529-171/+173
| | | | | | | | | | | | | | | | Provides safety against them accidentally becoming negative because of bugs in the calculations. Also does the same to CharArray and friends as they were strongly connection to the stream objects.
| * Remove unused FixedMemOutStreamPierre Ossman2019-11-151-52/+0
| |
| * Add sanity checks for PixelFormat shift valuesPierre Ossman2019-11-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Otherwise we might be tricked in to reading and writing things at incorrect offsets for pixels which ultimately could result in an attacker writing things to the stack or heap and executing things they shouldn't. This only affects the server as the client never uses the pixel format suggested by th server. Issue found by Pavel Cheremushkin from Kaspersky Lab.
| * Fix depth sanity test in PixelFormatPierre Ossman2019-11-151-1/+1
| |
| * Add unit test for PixelFormat sanity checksPierre Ossman2019-11-151-1/+2
| |
| * Handle empty Tight gradient rectsPierre Ossman2019-11-151-16/+21
| | | | | | | | | | | | | | | | | | | | We always assumed there would be one pixel per row so a rect with a zero width would result in us writing to unknown memory. This could theoretically be used by a malicious server to inject code in to the viewer process. Issue found by Pavel Cheremushkin from Kaspersky Lab.
| * Add write protection to OffsetPixelBufferPierre Ossman2019-11-152-0/+9
| | | | | | | | | | | | No one should every try to write to this buffer. Enforce that by throwing an exception if any one tries to get a writeable pointer to the data.
| * Restrict PixelBuffer dimensions to safe valuesPierre Ossman2019-11-151-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do a lot of calculations based on pixel coordinates and we need to make sure they do not overflow. Restrict the maximum dimensions we support rather than try to switch over all calculations to use 64 bit integers. This prevents attackers from from injecting code by specifying a huge framebuffer size and relying on the values overflowing to access invalid areas of the heap. This primarily affects the client which gets both the screen dimensions and the pixel contents from the remote side. But the server might also be affected as a client can adjust the screen dimensions, as can applications inside the session. Issue found by Pavel Cheremushkin from Kaspersky Lab.
| * Encapsulate PixelBuffer internal detailsPierre Ossman2019-11-154-50/+78
| | | | | | | | | | | | Don't allow subclasses to just override dimensions or buffer details directly and instead force them to go via methods. This allows us to do sanity checks on the new values and catch bugs and attacks.
| * Make ZlibInStream more robust against failuresPierre Ossman2019-11-156-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | Move the checks around to avoid missing cases where we might access memory that is no longer valid. Also avoid touching the underlying stream implicitly (e.g. via the destructor) as it might also no longer be valid. A malicious server could theoretically use this for remote code execution in the client. Issue found by Pavel Cheremushkin from Kaspersky Lab
* | Handle pending data in TLS buffersPierre Ossman2019-12-091-3/+5
| | | | | | | | | | | | There might be more bytes left in the current TLS record, even if there is nothing on the underlying stream. Make sure we properly return this when we aren't being requested to block.
* | Correctly calculate rects with no CopyRect supportPierre Ossman2019-12-091-1/+3
|/ | | | | The copied rects have already been merged in to the changed rects at this point if the client doesn't support the CopyRect encoding.
* Merge branch 'fix-mistake' of https://github.com/gschwind/tigervncPierre Ossman2019-10-141-2/+2
|\
| * fix to early remove of iterator in VNCServerST::removeSocketBenoit Gschwind2019-08-241-2/+2
| |
* | Fix bad PixelBuffer reference in VNCServerST::setPixelBuffer()Pierre Ossman2019-10-041-1/+1
| | | | | | | | | | We need to examine the incoming PixelBuffer, not the previous one (which might not even be valid).
* | Fix length checks in string conversion functionsPierre Ossman2019-09-251-16/+16
|/ | | | | | | | We need to check the buffer length before accessing the incoming string. Probably not a problem in practice as there should be a final null in most incoming strings. Issue found by Pavel Cheremushkin from Kaspersky Lab.
* Merge branch 'exclipboard' of https://github.com/CendioOssman/tigervncPierre Ossman2019-07-0131-88/+1629
|\
| * Support extended clipboard transfersPierre Ossman2019-07-0122-37/+807
| | | | | | | | | | | | | | Implements support in both client and server for the extended clipboard format first seen in UltraVNC. Currently only implements text handling, but that is still an improvement as it extends the clipboard from ISO 8859-1 to full Unicode.
| * Use UTF-8 in clipboard APIPierre Ossman2019-07-014-4/+234
| | | | | | | | | | In prepartion for better clipboard extensions that can send Unicode data between the client and server.
| * Improved clipboard APIPierre Ossman2019-07-0110-49/+342
| | | | | | | | | | Change the internal clipboard API to use a request based model in order to be prepared for more advanced clipboard transfers.
| * Add UTF-8 to/from ISO 8859-1 conversion routinesPierre Ossman2019-07-012-0/+175
| | | | | | | | | | We convert between UTF-8 and ISO 8859-1 (latin 1) in several places so create some common routines for this.
| * Clean up internal clipboard handlingPierre Ossman2019-07-0113-25/+30
| | | | | | | | | | | | We now filter incoming data, which means we can start assuming the clipboard data is always null terminated. This allows us to clean up a lot of the internal handling.
| * Make sure clipboard uses \n line endingsPierre Ossman2019-07-017-6/+74
| | | | | | | | | | | | This is required by the protocol so we should make sure it is enforced. We are tolerant of clients that violate this though and convert incoming clipboard data.
* | Remove max area parameter from Region::get_rects()Pierre Ossman2019-06-242-12/+5
| | | | | | | | | | It was unused and added complexity and bugs to the code. So let's remove it rather than trying to clean up a function no one needed.
* | Merge branch 'master' of https://github.com/lprylli/tigervncPierre Ossman2019-05-091-1/+1
|\ \ | |/ |/|