Commit Graph

2004 Commits

Author SHA1 Message Date
Pierre Ossman
256d8e2b3c Respect TLS version argument
The code handling it was lost in the switch from OpenSSL to GnuTLS.
Restore the functionality in the new code.
2019-09-16 09:24:49 +02:00
Pierre Ossman
9f14da3eb2 Revert "Always prompt for password if not provided via commandline."
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.
2019-09-03 16:07:58 +02:00
Pierre Ossman
1475092762 Avoid nesting stream macros
It only works by luck here, so avoid this style as bugs easily happen.
2019-06-13 14:23:02 +02:00
Markus Beth
5c900521f3 sec_decrypt() the correct amount of data
Save the correct amount of data to sec_decrypt() because after
inout_uint8p() the macro s_remaining(s) will find nothing left.
2019-06-13 14:12:25 +02:00
Pierre Ossman
6028c999ba Allow TLS to continue without system database
It will mean manual confirmation for users, but that is probably
better than outright refusal.
2019-06-04 16:53:13 +02:00
Pierre Ossman
e7bc37918c Don't use assert() for error handling
It is excessively harsh in its output, and it can be completely
compiled out which will give an incorrect behaviour.
2019-06-04 16:51:30 +02:00
Pierre Ossman
aa5164ede4 Fix protocol code handling new licenses
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.
2019-05-21 12:58:47 +02:00
Pierre Ossman
a88cd226bb Merge branch 'secfix' of https://github.com/CendioOssman/rdesktop 2019-05-08 13:55:46 +02:00
Pierre Ossman
a33814c478 Add comments for STREAM macros
Add some short descriptions that should hopefully make it easier
to understand what all these macros do.
2019-05-06 14:33:38 +02:00
Pierre Ossman
77758c3c18 Handle empty unicode strings from server 2019-05-06 14:33:38 +02:00
Pierre Ossman
f19c21d7d1 Fix memory leak in disk redirection
We kept allocating a data buffer for this stream in each call,
but never freeing it.
2019-05-06 14:33:38 +02:00
Pierre Ossman
25b8412333 Avoid poking around in STREAM internals
It's easy to make mistakes this way, and bypassed the normal bounds
checking. So make sure we always use macros or functions.
2019-05-06 14:33:38 +02:00
Pierre Ossman
489c43f382 Return STREAM objects from data generating functions
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.
2019-05-06 14:33:11 +02:00
Pierre Ossman
655c3d56df Clean up channel chunk sending code
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.
2019-05-06 14:33:05 +02:00
Pierre Ossman
c6d8b933c8 Avoid preallocated streams in tcp.c
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.
2019-05-06 14:33:05 +02:00
Pierre Ossman
75221eb3c5 Separate behaviour of out_uint8a and out_uint8p
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.
2019-05-06 14:33:05 +02:00
Pierre Ossman
6268b44f06 Add macro to check remaining length of STREAM
Avoids poking around in the internals, and also makes the code
easier to read.
2019-05-06 14:33:05 +02:00
Pierre Ossman
3e340f2f20 Add explicit STREAM allocation function
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.
2019-05-06 14:33:05 +02:00
Pierre Ossman
dd0217f372 Remove in_skip() in favour of in_uint8s()
It was barely used and it was confusing having two macros doing the
same thing. Standardise on the more common variant.
2019-05-06 14:33:05 +02:00
Pierre Ossman
90219aac41 Add bounds checks to stream handling
Protect against buffer overflow and overrun bugs in the protocol
handling.
2019-05-06 14:33:05 +02:00
Pierre Ossman
e099d79879 Remove dangerous s_check()
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.
2019-05-06 14:33:05 +02:00
Pierre Ossman
de59a100ea Mark rd_protocol_error() as "noreturn"
This allows the compiler to optimize things better and give better
warnings as it knows it will never return from this function.
2019-05-06 14:33:05 +02:00
Pierre Ossman
e1537061bf Fix packet debug output in rdp_protocol_error()
We're trying to print the entire packet, not just what's left.
2019-05-06 13:30:13 +02:00
Pierre Ossman
d8b0f3782a Give source code info in rdp_protocol_error()
Makes it easier to debug things by seeing exactly where the protocol
handling crashed.
2019-05-06 13:29:44 +02:00
Pierre Ossman
092fc20921 Use STRNCPY() macro in smart card code
The previous code did not do a proper bounds check and could result
in buffer overflows and unterminated strings if long names were
specified.
2019-05-06 13:28:31 +02:00
Pierre Ossman
f0cab337ea Merge branch 'set-version-to-1.8.99' of https://github.com/paulmenzel/rdesktop 2019-04-18 10:21:43 +02:00
Paul Menzel
8ea3fab052 Set master version to 1.8.99 to be greater than 1.8.x versions
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
2019-04-12 16:52:48 +02:00
Pierre Ossman
48b184477e Fix bad call to strncat() 2019-04-12 14:37:24 +02:00
Pierre Ossman
cf95138c9b Don't use strncpy() when not needed
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.
2019-04-12 14:37:24 +02:00
Pierre Ossman
df94870c91 Remove unused variables and functions 2019-04-12 14:37:24 +02:00
Pierre Ossman
836e008853 Fix fast path stream array
There are 16 possible codes, not 15.

(even if we currently don't know what to do with the last code)
2019-04-12 14:37:24 +02:00
Markus Beth
dc7ee56de4 support status flags of newer GnuTLS
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.
2019-04-07 22:45:32 +02:00
Pierre Ossman
a4bdfcfe76 Don't check certificate purpose on older GnuTLS
The feature was added in 3.6.0, so avoid compilation errors if
building with an older GnuTLS.
2019-03-01 11:17:40 +01:00
Alexander Zakharov
49caf6e7c3
Merge pull request #313 from markusbeth/fix_format_strings
fix "Too few arguments to formatting function"
2019-02-08 09:27:58 +03:00
Markus Beth
e7fb28f28e fix "Too few arguments to formatting function" 2019-02-07 23:52:24 +01:00
Markus Beth
b02996136b Fix memory leak
Variables of type mpz_t must be cleared with mpz_clear().
2019-02-05 22:48:48 +01:00
Markus Beth
caae8af53c Fix memory leaks on certificate handling
Call rdssl_cert_free() for all certificates created with
rdssl_cert_read().
2019-02-05 22:48:32 +01:00
Markus Beth
35d8c932ab Fix memory leaks on certificate handling
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().
2019-02-05 22:34:10 +01:00
Markus Beth
116e125139 Fix memory leaks
The return values of XGetAtomName() have to be freed with XFree().
2019-02-05 22:34:10 +01:00
Alexander Zakharov
85f99edd65 Update copyrights 2019-02-01 11:21:32 +03:00
Alexander Zakharov
d4fe8e8421
Merge pull request #309 from markusbeth/fix_heap_overflow
fix heap overflow in libtasn_read_cert_pk_parameters
2019-02-01 10:46:13 +03:00
Markus Beth
30b9571586 fix heap overflow in libtasn_read_cert_pk_parameters
use correct size to memcpy() the exponent data in
libtasn_read_cert_pk_parameters
2019-02-01 08:30:19 +01:00
Alexander Zakharov
ff875768ed
Merge pull request #307 from derfian/drive-redirection-offsets
Fix device redirection offsets
2019-01-31 13:20:04 +03:00
Karl Mikaelsson
5351182410 Fix problems with transferring large files
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>
2019-01-31 10:51:19 +01:00
Henrik Andersson
8ea0b446ef Add report of activation/expiration dates 2019-01-31 10:40:12 +01:00
Henrik Andersson
fcf3e923ba
Merge pull request #298 from rdesktop/GnuTLS
Replace OpenSSL with GnuTLS Nettle, libtasn1
2019-01-30 17:34:07 +01:00
Henrik Andersson
9acb0ccaa3 Dont use status bits not available in v3.2.0 2019-01-30 17:16:14 +01:00
Henrik Andersson
e021920813 This commit have multiple fixes:
- Break out code from tcp.c into utils.c for handling
   of adding certificate exceptions

 - Add clarifications why a certificate is untrusted

 - Add simplified certificate view with fingerprints for
   review.
2019-01-30 16:12:15 +01:00
Karl Mikaelsson
aa5935cb11
Merge pull request #305 from wallix/master
Fix checking the length of remaining data in stream for very compact orders.
2019-01-30 11:07:13 +01:00
Pierre Ossman
17363d9e4d Get a private copy of the redirect cookie
We accidentally just changed the pointer rather than copying the
cookie in to our freshly allocated buffer. This caused problems
after 74b2129e as we started freeing the stream buffers on
disconnect.
2019-01-30 11:00:23 +01:00