Commit Graph

79 Commits

Author SHA1 Message Date
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
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
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
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
Alexander Zakharov
85f99edd65 Update copyrights 2019-02-01 11:21:32 +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
Alexander Zakharov
758f7b5156 scard: Fix buffer overflow
Even though we can detect that the server buffer is too small to
receive the APDU result we don't prevent the actual copy of this result
to allocated buffer which results in overflow.
2019-01-23 16:12:21 +03:00
Alexander Zakharov
774a657975 Handle insufficient server side buffer for smartcard operations
We should pay attention to OutputBufferLength of DR_CONTROL_REQ
and send STATUS_BUFFER_TOO_SMALL if it's insufficient for returned
result.
2019-01-23 16:12:21 +03:00
Markus Beth
55c85b55e7 fix lgtm: 'Too few arguments to formatting function'
maybe a typo that got copied around and leads to too few arguments in
formatting functions
2018-11-06 22:23:25 +01:00
Henrik Andersson
c16b74a974 Run indent-all.sh script on source 2018-10-29 15:53:57 +01:00
Alexander Zakharov
b77d00ceba Fix TS_SCardEstablishContext/TS_SCardIsValidContext
Current approach for TS_SCardEstablishContext() causes
Windows not to detect scard reader insertion in a case
when rdesktop was lauched without attached reader(s).

Thanks to demansong@gmail.com for the help to pinpoint this issue.
2018-04-27 13:46:45 +03:00
Rostislav Kondratenko
58f855a3a2 Enable PnP sc reader notifications 2018-04-27 13:46:45 +03:00
Rostislav Kondratenko
2abd25ae2a Fix scard logon 2018-04-27 13:46:45 +03:00
Alexander Zakharov
e3fbadfcf5 Fix scard handling of PCSCv2 Part 10.
We must not modify any features codes before sending
them off to Windows.
2018-02-09 14:34:01 +03:00
René Genz
9e99dd52d6 Fix minor spelling mistakes 2017-11-02 01:01:44 +01:00
Henrik Andersson
8c83f8957b Fix SCARD_AUTOALLOCATE handling
SCARD_AUTOALLOCATE is a define with value -1, which is compared
to an uint32. There was some missassumtion of whenever its -1 or
0xffffffff through the code.
2017-10-23 08:43:35 +02:00
Henrik Andersson
0d707ae103 Fix sign-compare compiler warnings 2017-10-20 13:30:42 +02:00
Henrik Andersson
896a923f55 Markup unused parameters 2017-10-20 11:05:52 +02:00
Henrik Andersson
267db2ceff Fix compile warnings about unused variables 2017-10-17 10:32:40 +02:00
Karl Mikaelsson
cebd4ad016 Move all Smart Card error messages to the debug level
Running rdesktop with smart card redirection could lead to scenarios
where rdesktop keeps producing error messages about the Smart Card
redirection when there isn't really an error. I don't believe that we
should log an error if the underlying PC/SC interface reports
SCARD_E_NO_SERVICE.

The logged information could be useful for developers in debugging
scenarios, so I'm keeping is as Debug rather than removing it
outright.
2017-10-11 17:24:46 +02:00
Henrik Andersson
41b8e1ce06 Merge pull request #160 from derfian/remove-make-proto
Remove infrastructure to auto-generate proto.h
2017-10-06 10:35:36 +02:00
Alexander Zakharov
ed3726a9fa Handle the lack of SCARD_CTL_CODE on Mac 2017-10-05 19:47:59 +03:00
Karl Mikaelsson
1f13c85583 Remove infrastructure to auto-generate proto.h
If proto.h is supposed to be auto-generated it should probably not be
present in the repo at all. Re-running cproto showed that proto.h has
been manually edited for quite some time, so this just makes this the
only workflow.

It also gets rid of a bit of #ifdefs, so that's nice.
2017-10-05 15:18:13 +02:00
Karl Mikaelsson
dca441c4e6 Don't log warnings/errors from TS_SCardGetStatusChange at all
Not sure why I thought the user needed to see this at all.
2017-10-04 17:11:02 +02:00
Karl Mikaelsson
96faa24bd5 Don't log common Smart Card error codes as rdesktop errors
The proper thing to do would be to forward the errors to the server
and let it deal with it. No need to present these as errors to the
user.
2017-10-04 15:20:46 +02:00
Henrik Andersson
f616b2c1f9 Release scard context if not used 2017-07-07 13:12:38 +02:00
Henrik Andersson
7d8675074f Fail SCardEstablishContext if no readers connected
Windows smartcard application generally behaves better with polling of smartcard
subsystem availability than when there are no smartcard readers available.

This is a potential workaround for issue #109
2017-03-29 13:45:04 +02:00
Henrik Andersson
b37cbe9abd Refactor for cleaner code flow 2017-03-29 13:36:43 +02:00
Henrik Andersson
87d8d123b8 Rework the logging system
This commit will add a logging system to solve the problem that
one actually need to recompile rdesktop from source to enable
different debug logging.

- Same logging api  for all kind of logging and messages to
   end user.

- Adding -v for verbose output when running rdesktop.

- All messages are logged into a subject and with a type, eg:

     logger(Keyboard, Notice, "Autos-electing %s based on locale.", locale);

- Debug logging is enabled trough a environment variable RDEKSTOP_DEBUG,
  which specifies subjects of interest, comma separated. There is a special
  subject named All which includes all subject for debug loggin. There is also
  a simple logic opeartor '!' = NOT which can be used in combination like:

    RDESKTOP_DEBUG=All,!Graphics,!Sound

  Which would give debug log output for All subject except Graphics and Sound.
2017-01-26 14:19:40 +01:00
remijouannet
b46639ad3c indent-all.sh 2016-05-24 18:02:22 +02:00
Henrik Andersson
761cc053e2 Fixes a bug with Windows Server 2012 r2 and smartcard
redirection were the RDPDR channel is shutdown by server.

The RDPDR channel is shutdown by server when responses from
abdonend iorequests are received on a reinitialized RDPDR
channel. This fix adds epochs for RDPDR channel and tags 
iorequest to specific epoch to handle abdonend iorequest.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1836 423420c4-83ab-492f-b58f-81f9feb106b5
2014-09-11 11:54:46 +00:00
Henrik Andersson
fffb479e0c Workaround for bug in pcsc lite where timeout value 0
for SCardGetStatusChange() behaves just like INFINIT.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1835 423420c4-83ab-492f-b58f-81f9feb106b5
2014-09-11 11:15:46 +00:00
Peter Åstrand
3dbb64050d Ran indent-all
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1738 423420c4-83ab-492f-b58f-81f9feb106b5
2013-09-16 12:45:47 +00:00
Henrik Andersson
69b6171fd1 Remove undocumented fallback codeblock which existence is not motivated.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1733 423420c4-83ab-492f-b58f-81f9feb106b5
2013-08-29 13:27:35 +00:00
Henrik Andersson
982fd425a3 Fixes a issue with 64bit portability.
Fix for bug #366



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1729 423420c4-83ab-492f-b58f-81f9feb106b5
2013-08-12 09:52:08 +00:00
Pierre Ossman
e0766aae22 Don't screw up the attribute ID for SCardGetAttr(). It
worked by pure luck in some cases, and failed in the rest.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1724 423420c4-83ab-492f-b58f-81f9feb106b5
2013-07-05 14:32:43 +00:00
Pierre Ossman
72dd2ac5be Do a proper parsing of the ReaderState structure. We did not
handle NULL szReader properly previously.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1723 423420c4-83ab-492f-b58f-81f9feb106b5
2013-07-05 11:44:03 +00:00
Henrik Andersson
6e7f45f3e7 Adding forceOutAlignemnt(out, 8) which is just cosmetics.
Thanks goes to Arvo for his findings and provided patch of the 
bugs fixed in r1649, r1650 and this commit.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1651 423420c4-83ab-492f-b58f-81f9feb106b5
2011-12-07 09:49:44 +00:00
Henrik Andersson
d8cc551013 Fixes serious bug were output are aligned before all data is available.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1650 423420c4-83ab-492f-b58f-81f9feb106b5
2011-12-07 09:25:27 +00:00
Henrik Andersson
7e39d5a450 Fixes an invalid check for memory allocation.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1649 423420c4-83ab-492f-b58f-81f9feb106b5
2011-12-07 09:20:39 +00:00
Henrik Andersson
abb83dbd6f This patch fixes smartcard handle problems on 64bit version
of rdesktop, this is jsut a hack to fix the problem with
smartcard imlpementation temporarly due the smartcard impl.
really needs to be reimplement for a cleaner code and proper
handling.

- Ripped out the old magic scard handle code to be replaced
  with mappings the works on 64bit rdesktop.

- Added a handle map to support mapping between a 64bit handle
  and 32bit eg:  pcsclite <- 64bit-> rdesktop <- 32bit -> WTS server.

- Added handle mapping for the context handle to which old code didn't
  event respected at all eg. 64bit context handled truncated to 32bit.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1646 423420c4-83ab-492f-b58f-81f9feb106b5
2011-11-24 13:19:52 +00:00
Henrik Andersson
aa517c7c39 pcsclite >= 1.6.2 does not include the type SCARD_READERSTATE_A which
breaks compilation, change code to use SCARD_READERSTATE which
is the new name and is also an typedef of the old SCARD_READERSTATE_A
from pcslite <1.9.2 versions.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1643 423420c4-83ab-492f-b58f-81f9feb106b5
2011-11-15 08:40:41 +00:00
Pierre Ossman
1da6ed30e5 Some operations consist of just the control code, no data.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1599 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-22 13:06:50 +00:00
Pierre Ossman
b82d367a4b Translate the response to control code 3400 as it contains embedded control
codes in the local encoding.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1598 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-22 13:06:16 +00:00
Pierre Ossman
91af7ba5fc Let bogus control codes through with a warning, in case it might work
anyway.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1597 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-22 13:05:26 +00:00
Pierre Ossman
7e759ced83 Add copyright notice.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1596 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-14 07:36:52 +00:00
Pierre Ossman
1ac2cd144e Control codes to SCardControl() are platform dependent so we need to do
some translation before passing them on.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1595 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-14 07:35:55 +00:00
Pierre Ossman
4635dfc148 Remove undocumented voodoo in SCardGetStatusChange() as it causes the
system version to return immediately, causing CPU intensive loops.


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1594 423420c4-83ab-492f-b58f-81f9feb106b5
2010-06-14 07:35:00 +00:00
Peter Åstrand
aab770d625 Indented
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1562 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-27 07:40:47 +00:00
Peter Åstrand
60e82d86ef Reset smart card state before reconnect. This fixes stability problems
when using smart cards in conjunction with RandR. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1561 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-26 12:23:53 +00:00