These are not valid outside of UTF-16 so seeing them in a UTF-8 sequence
means that something is wrong with that sequence. Best to filter them
out rather than letting them propagate and have unknown effects.
We should handle this in the low-level protocol code as much as possible
to avoid mistakes. This way the rest of the code can assume that strings
are always UTF-8 with \n line endings.
The previous method isn't compatible with CMake's try_compile() as it
will respect CMAKE_EXE_LINKER_FLAGS, but not CMAKE_C_LINK_EXECUTABLE and
friends. This results in the default libraries being completely missing,
and the compile test failing.
The coordinates we get are relative the root window of each screen, so
we can only trust them if we are on the same screen. So let's explicitly
check that we are still getting events from the expected screen by
checking the root window field of the event.
An assert will kill the entire server, which is overly harsh when there
is a problem with a single connection. Instead, throw an exception which
will just disconnect that specific client.
VNCSConnectionST clipboard functions should check state before access.
Clipboard functions may run on connections that are not yet at
RFBSTATE_NORMAL. Due to recent hardening of the accessCheck() function,
it is important to validate that the state is RFBSTATE_NORMAL before
calling accessCheck().
Fixes #1599.
It is easy to get confused if these methods modify the existing object,
or return a new one. So let's mark the return value as critical so the
compiler can help out if someone gets it wrong.
This can have unexpected consequences as some code may rely on it being
a simple variable. Instead to what we do in Socket, which is to define a
unique name for getting socket error numbers.
These files don't use anything from this header, so remove the include.
This exposes some missing includes in other places, though. So add an
explicit include in the files that were relying on an indirect
inclusion.
It's more standard and familiar than our custom CharArray type, and it
still gives us automatic freeing of the buffer.
We could probably have used std::unique_ptr instead, but we are
currently targeting older compilers where C++11 isn't standard yet.
Get rid of all the magical re-allocation and shuffling and instead just
return a new set of strings that is fully splitted. Will consume a bit
more memory, but is a lot safer to use as there is less confusion about
ownership of memory.
We mostly use classical C strings, but the memory management around them
can get confusing and error prone. Let's use std::string for the cases
where we need to return a newly allocated string.
A blank string might be very confusing, depending on where this will be
used. Let's give something more visible back in the cases where we
cannot get the proper name for the peer.