Pierre Ossman
337dbc3922
Return std::string instead of dynamic allocations
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.
1 year ago
Pierre Ossman
dde95fccca
Specify expected array size in arguments
The compiler doesn't enforce this, but it at least documents the
expected array size.
1 year ago
Pierre Ossman
d608a30d57
Use fixed size character buffer
We know the needed space here, so let's keep it simple with a constant
size string buffer.
1 year ago
Pierre Ossman
ef8c84eb75
Remove trailing slash from getvnchomedir()
It should return a path to the directory itself, just like its sister
function getuserhomedir().
1 year ago
Pierre Ossman
803a6ae087
Namespace directory functions
All library functions should be in a proper namespace.
1 year ago
Pierre Ossman
334398153b
Better fallback for missing peer address
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.
1 year ago
Pierre Ossman
5c1ac16776
Return static char buffer from some methods
This mimics how some system functions (like inet_ntop()) work, and
avoids complexity around ownership of the returned string buffer.
The downside is that the string must be consumed directly as it will be
overwritten on the next call, but that is not an issue with the current
usage.
1 year ago
Pierre Ossman
1af2a56f75
Replace tabs with spaces
Use the same indentation we use in all other files.
1 year ago
Pierre Ossman
51347ef875
Remove unneded string duplication
It's unclear why this was initially added. The function takes string
constants, so it is not going to modify these.
1 year ago
Pierre Ossman
7f20bff356
Remove unneeded CharArray:s
Avoid complicating things by moving things in to a second buffer here as
there is no need for it.
1 year ago
Pierre Ossman
741300728a
Use StringParameters directly
We don't need to make extra copies of the string in most cases, so let's
simplify the code and access the string directly when we can.
1 year ago
Pierre Ossman
77f0a61ec8
Get rid of TCHAR magic
We never use Windows' "UNICODE" mode anyway, so let's get rid of this
complexity.
1 year ago
Pierre Ossman
2047dae22f
Return std::vector instead of dynamic allocation
This makes memory management more clear and robust when using these
helper functions.
1 year ago
Pierre Ossman
ea6afa9b79
Avoid duplicating configuration setting
Let the string helpers call the more fancy setParam(). This makes sure
we can avoid duplicating things.
1 year ago
Pierre Ossman
cee09051e6
Make sure length is reset on assignment
Otherwise the old length is preserved, which will result in NULL pointer
dereferencing if the parameter is ever accessed.
1 year ago
Pierre Ossman
cf931f8c9a
Clean up BinaryParameter typing
This is explicitly a byte sequence, so let's try to keep a consistent
typing.
1 year ago
Pierre Ossman
07e541678c
Move hex conversion helpers to util
These are used here and there so let's make them more general rather
than hiding them in the stream classes.
1 year ago
Pierre Ossman
d98720b736
Use std::vector for basic data arrays
Avoid our own custom types in favour of what's already included with
C++.
1 year ago
Pierre Ossman
6881c895ab
Use stdint types
Avoid having our own custom stuff and instead use the modern, standard
types, for familiarity.
1 year ago
Pierre Ossman
baca73d032
Use templates for optimized code
Avoid preprocessor magic and instead rely on templating to generate
optimized functions for performance critical code.
1 year ago
Pierre Ossman
bf0fb9129d
Fix CRLF line endings
Everything else uses LF line endings, so fix up the few stray ones.
1 year ago
Pierre Ossman
7a36fb8ca7
Use __attribute__:s directly
These are supported by gcc and clang, and I don't think MSVC works well
with our code anyway, so let's keep things simple and use these
directly.
1 year ago
Pierre Ossman
03ca97526b
Remove old mingw compatibility code
This isn't needed with modern build environments, and can even conflict
with them.
1 year ago
Pierre Ossman
cdec36858e
Protect key variables from setjmp()
If we don't mark these as volatile then they might get reset on
longjmp() and the code will misbehave.
1 year ago
Pierre Ossman
e75051a62a
Remove useless const specifiers
These are just values, so setting const on them has no effect as the
caller will get a copy.
1 year ago
Pierre Ossman
23cabcaa9e
Explicitly mark switch case fall through
This allows us to separate accidental fall through from explicit ones,
which allows us to turn on such checks in the compiler.
1 year ago
Pierre Ossman
e866c7de65
Fix RSA-AES state machines
If there isn't enough data, then the client reading the hash will fall
down and try to read the subtype instead, which isn't correct.
Invert the logic so we get a more consistent way through where we only
break out when there is insufficient data.
Do the same for the server code, for consistency.
1 year ago
Pierre Ossman
3a1c46ff75
Explicitly mark unused parameters
This allows us to separate accidentally unused, from explicitly unused
parameters, which allows us to turn on such checks in the compiler.
1 year ago
Pierre Ossman
a4fa1d7188
Don't include palette to full color methods
They have no need for it, so let's simplify things.
1 year ago
Pierre Ossman
01afd4a74d
Remove unused flags to decoder contexts
Everything in flags is already handled at a higher level.
1 year ago
Pierre Ossman
a18fd2942a
Stop supplying flags to clipboard peek handler
The flags should always be empty anyway.
1 year ago
Pierre Ossman
ca0955c3fe
Mark system include paths correctly
This makes sure the compiler doesn't complain about problems in those
files.
1 year ago
Dinglan Peng
40e24436e3
Add client-side support for the MSLogonII security type.
1 year ago
Dinglan Peng
6c4c7c8551
Add client-side support for the DH security type.
1 year ago
Pierre Ossman
e46d2c36d8
Flush decoder errors on close()
We don't want any stray exceptions as we are cleaning up, so handle any
still pending decoder errors by just logging them. We are already
shutting down so there is no need to abort the connection here.
1 year ago
Pierre Ossman
b98ff69145
Don't enable RSA-AES by default in servers
These require a key to have been set up on the server beforehand, so
they do not give a good default experience as clients will be unable to
connect.
1 year ago
Catherine Tower
645c1f2aea
Ignore whitespace around components of host-and-port specification
This is to make the code more tolerant of typos when entering a hostname
1 year ago
Pierre Ossman
4b12f80cf4
Fix incorrect nettle library references
1 year ago
pdlan
484ae7a2ea
Add support for RSA-AES security types
1 year ago
Pierre Ossman
7b1be722af
Fix stream check for InStream::getptr()
This call should have been preceeded by hasData() or avail(), just like
all other accessor functions.
1 year ago
Pierre Ossman
f2bbb6b303
Move include_directories() to proper places
We should scope these as narrowely as possible to avoid side effects.
1 year ago
Pierre Ossman
79329c0a8f
Use BufferedOutStream in more streams
Avoid duplicating all the memory mangement, and instead use the
BufferedOutStream as a base clase for all out streams that need an
intermediate buffer.
1 year ago
Pierre Ossman
d67657e67d
Remove unused CSecurity::description()
1 year ago
Pierre Ossman
0ae1557ed9
Make BufferedInStream allocation more available
Allow subclasses to call it, instead of it being strictly internal. This
is useful when a subclass can only provide data in minimum sized chunks.
1 year ago
Pierre Ossman
ece16218a4
Safely discard large (extended) clipboard contents
Avoid having to buffer everything we want to discard, and instead do it
piece by piece. This is more efficient, and avoids hitting any limits on
the buffering.
Note that this is safe here because we already know we have all the
compressed data. It would not be safe for a general input stream.
1 year ago
Pierre Ossman
ff9ccc21b8
Properly restore cork state when changed
These streams both need to change the corking state temporarily, but it
is important it is restored to the previous state or things might get
messed up.
For the zlib stream it would just leave things uncorked, which still
works but is less efficient.
But for the TLS stream it might make things very unresponsive as the
corking might be left on permanently, delaying packets indefinitely.
1 year ago
Pierre Ossman
9a137eb8e7
Only implicitly flush on uncorking
There is no point flushing when corking was enabled, as we might then
push out a small buffer that the corking otherwise would have preserved.
1 year ago
Martins Mozeiko
03a2386b3d
Workaround for MFT cropping in H264 decoding
It seems MFT h264 decoder does not support frame cropping. Which
means that if frame width or height is not multiple of 16 then
decoded output can potentially be used with wrong offset. This
code adds explicit parsing of SPS to extract cropping information
to use, and will apply cropping if reported size differs from
expected.
2 years ago
Pierre Ossman
101cef956d
Find FFMPEG using pkg-config
This is the standard method of finding it on Unix systems, so make sure
we use it. Still keep a fallback, though, for other systems, e.g.
Windows.
2 years ago
Pierre Ossman
4cf31302a1
Fix up ffmpeg header and library handling
FFMPEG is needed by the RFB library, so all the details about it should
only be applied there and not for other components.
2 years ago