The conversion from OpenSSL to GnuTLS (or GMP in this case) got
the endianness mixed up in the initial security handshake. It got
it wrong in two places though, which cancelled each other out when
X.509 certificates are used. But servers using the older system,
like Windows XP, would fail the handshake as different endianness
was then used when reading the RSA key and when using it.
Old versions of Windows (e.g. XP) sends a cropped packet in some
cases. It still contains all the important parts, so let's be
tolerant of this misbehaviour.
This reverts commit 1aaafc80c0.
This change has caused a lot of issues, so we need to pause this for
now and figure out a way to make the transition smoother.
s_seek() is a macro, so it is dangerous to use complex expressions
in it as they may be evaluated multiple times and at incorrect times.
In this case we ended up trying to jump to an incorrect offset.
Work around this by having a dedicated variable for the target offset.
Use a consistent style of returning a new STREAM object from functions
that output data, rather than requiring an existing structure to be
passed in. This generally makes the memory management more straight
forward and allows us to do more proper bounds checking of everything.
This also adds some new STREAM macros to make it easier to manage
them without poking around in the internal structure.
Make sure the buffer handling is a bit more sane so we can verify
offsets and boundaries. Also adds some more helper macros to shuffle
data between two different STREAM instead of trying to poke around
in the internals.
We don't know when the caller might be done with a stream, so we
can end up with code overwriting things in a stream that is in use
elsewhere.
Solve the issue by returning a new stream each time and leave it
up to the callers to free it.
Make them more match in_uint8a and in_uint8p in that one copies and
the other just gives you a pointer and it is up to the caller how
to fill it in. This can be useful when other APIs are used to
generate the data as it avoids a temporary buffer.
Avoids mistakes by making sure everyone allocates these the same
way.
The smart card code still has manual allocation because it has it's
own magical memory management.
This macro checks if a pointer is valid _after_ we've already used
that pointer. So it will only trigger if we're already performed some
for of buffer overflow. As such, it provides little to no value and
can only server to encourage broken behaviour.
Let's remove it and replace it with proper bounds checking before
access instead.
Currently, the version number of releases made from the branch 1.8.x are
greater than the version in the master branch (1.8.3post).
That makes life a little harder for packages wanting to package the code
from the master branch.
So, set the version to 1.8.99, ensuring with a high probability, that
the version will be greater than all 1.8.x releases.
Fixes: https://github.com/rdesktop/rdesktop/issues/325
It upsets the compiler warnings when you do strncpy() with the
source buffer size as the limit. It is also unnecessary to use
strncpy() here as we just allocated a buffer guaranteed to be
large enough.
Support status flags of newer GnuTLS in _utils_cert_get_status_report
with the appropriate GnuTLS version guards.
This code (without the version guards) was already part of the GnuTLS
branch and was removed in 9acb0cca. I think it is helpful to add it
again to get better error hints on certificate problems when using a
newer GnuTLS.
Certificates initialized with gnutls_x509_crt_init() must be freed with
gnutls_x509_crt_deinit().
Memory allocated with malloc() should be freed with free() not
gnutls_free().
The entire device redirection framework is documented to use 64-bit
offsets rather than 32-bit offsets. This should fix any problems
transfering large files with rdesktop.
Co-Authored-By: gpatel-fr <44170243+gpatel-fr@users.noreply.github.com>