summaryrefslogtreecommitdiffstats
path: root/common/rfb
Commit message (Collapse)AuthorAgeFilesLines
...
* | Fix UTF-16 encoding/decoding of high code pointsPierre Ossman2020-10-051-3/+4
| | | | | | | | | | Everything outside of BMP was handled incorrectly and was coded as completely different code points.
* | Return the correct number of consumed UTF-8 bytesPierre Ossman2020-10-051-0/+2
| | | | | | | | | | | | | | | | This would mess up most conversions from UTF-8 as the caller wouldn't know how far to step to get to the next valid character, resulting in markers for invalid data to be injected here and there. Also add some unit tests to avoid this reoccurring.
* | Merge branch 'tlstofu' of https://github.com/CendioOssman/tigervncPierre Ossman2020-09-081-90/+73
|\ \
| * | Properly store certificate exceptionsPierre Ossman2020-05-211-90/+73
| |/ | | | | | | | | | | | | | | | | | | The previous method stored the certificates as authorities, meaning that the owner of that certificate could impersonate any server it wanted after a client had added an exception. Handle this more properly by only storing exceptions for specific hostname/certificate combinations, the same way browsers or SSH does things.
* | Hide base SConnection methods from VNCServerSTPierre Ossman2020-08-212-2/+4
| | | | | | | | | | It should be using the safe wrappers for everything so make sure it cannot bypass those and call the SConnection methods directly.
* | Call correct wrappers for clipboard handlingPierre Ossman2020-08-211-3/+3
| | | | | | | | | | | | | | We incorrectly called the underlying functions instead of the safe wrappers for the new clipboard functions. This had the effect of a) crashing the entire server if one of these functions failed, and b) not respecting the settings disabling the clipboard.
* | Enhanced ComparingUpdateTracker to crop changed blocksMark Mielke2020-07-221-4/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 64x64 changed block can be large for fine changes such as cursor movement and typing in terminal windows, or an update to a clock. If the block can be efficiently cropped, this will reduce latency and bandwidth. Every pixel cropped is a pixel less to analyze, encode, transmit, and decode. The previous code already detected the top of the change in order to determine if the block had changed. However, it did not use this information to reduce the size of the change rectangle, nor did it calculate any of the other edges. The new code introduces detection of the other edges, and uses the information to build a reduced area change rectangle. This has the additional effect of reducing the number of discrete pixel values in the change block which may allow a more efficient encoding algorithm to be selected. As this section of code is performance sensitive, the method of detecting the edges has been optimized to quickly fall back to pessimistic values as soon as a single comparison fails on each edge. In the case that full 64x64 block are changing, there will be three extra comparisons per block. In cases where the change rectangle can be reduced from 64x64, the reduced size of the change rectangle represents reduced effort to encode, transfer, and decode the contained pixels. In the case of images with high frequency changes, which specifically includes text, the lossy JPEG encoding can be highly distorted, especially with JPEG level 6 or less. The quick flash from a distorted JPEG to a lossless JPEG can appear as a flickering to some people. This effect was more obvious when the surrounding area is not expected to change, but is being distorted anyways due to being part of the 64x64 blocking algorithm. In the case of a user typing in a terminal window, this change may commonly reduce the number of pixels updated with every character typed from 4096 pixels (64x64) to 640 pixels (32x20) or less.
* | Fix non-functional MaxDisconnectionTimePierre Ossman2020-06-181-5/+5
| | | | | | | | | | | | Since 8e09912 this wasn't triggered properly as we checked if all clients were gone before we actually removed the last client from our list.
* | Merge branch 'regions' of https://github.com/CendioOssman/tigervncPierre Ossman2020-06-154-143/+60
|\ \
| * | Get rid of magical assignment to RegionPierre Ossman2020-05-183-36/+2
| | | | | | | | | | | | Might as well make these explicit so the cost is apparent.
| * | Switch region code to pixmanPierre Ossman2020-05-013-114/+65
| |/ | | | | | | | | This is the current upstream so let's make use of it to get the latest in features and fixes.
* | Remove unused variablePierre Ossman2020-05-311-1/+0
| |
* | Fix JpegCompressor::overrun() type changePierre Ossman2020-05-311-1/+1
| | | | | | | | | | The method it overloads got tweaked some time ago, so we need to make sure this method follows suit.
* | Send response for refused SetDesktopSizematt3356722020-05-291-3/+4
| | | | | | | | | | Sends response for SetDesktopSize as per the community wiki specification
* | Reject too large screen resize requestsPierre Ossman2020-05-231-0/+5
|/ | | | | We'll just crash later if we try to use such a large screen, so reject the request from the client instead and keep the server running.
* 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.
* 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-2016-88/+171
|\
| * 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.
| * Use size_t for lengths in stream objectsPierre Ossman2019-11-155-16/+17
| | | | | | | | | | | | | | | | 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.
| * 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-154-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | 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
|\ \ | |/ |/|
| * Fix wrap-aware isAfter function in Congestion.cxxLoic Prylli2019-04-271-1/+1
| | | | | | | | | | | | | | | | Result of overflow on signed integer arithmetic is undefined in C/C++ standard. So in previous version clang was compiling the statement as (int)a > (int)b (i.e. assuming no overflow), which leads to incorrect result. Correct deterministic behavior means doing overflow arithmetic as unsigned, i.e. a != b && a - b <= UINT_MAX / 2
* | Remove unneeded logging from ZRLE decoderPierre Ossman2019-04-291-2/+0
| | | | | | | | | | We will log the exception, so avoid direct writes to stderr by simply removing these log lines.
* | Do proper logging rather than fprintf(stderr, ...)Pierre Ossman2019-04-295-12/+21
| |
* | Remove commented out loggingPierre Ossman2019-04-291-2/+0
|/
* Increase version string buffer size for gccPierre Ossman2019-04-011-1/+1
| | | | | | There is some bug in gcc's new -Werror=format-overflow that makes it think majorVersion could end up being very large. Increase the target buffer for now to keep gcc happy.