Commit Graph

254 Commits

Author SHA1 Message Date
Ruben De Visscher
1835a39aaf Fix inconsistent cBytes value between WinScard and pcsc-lite. 2018-04-24 10:33:44 +02:00
Armin Novak
2517755d25 Fixed thread function return and parameters. 2018-03-07 14:36:55 +01:00
Jukka-Pekka Virtanen
2e8f2c693d [MS-RDPESC] 2.2.2.18 Status_Call.cbAtrLen: Unused. MUST be ignored upon receipt.
The [MS-RDPESC] clearly states in section 2.2.2.18 that Status_Call's
cbAtrLen must not be used when generating Status_Return response. This
is also how FreeRDP 1.1 behaves.
2018-01-11 16:23:15 +02:00
Armin Novak
bb7ba6ff26 Fixed smartcard related scanbuild warnings. 2017-12-21 10:53:36 +01:00
Armin Novak
6a21bdae3d Fixed various scanbuild warnings. 2017-12-21 09:34:35 +01:00
Bernhard Miklautz
36c6478627 fix client/smartcard: indentation and return value
Integrate feedback from pull request review.
2017-12-14 16:21:19 +01:00
Bernhard Miklautz
5a1c0081c5 fix smartcard: SCardStatus unicode handling
* fix StatusW_Call to rely and use SCardStatusW
* fix trace call in  StatusW_Call - needs to be called after the sizes
  are set
* unify SCardStatus functions for pcsc - let the internal function handle unicode directly

This fixes an issue with size calculations of SCardStatusW.
2017-12-14 15:46:14 +01:00
Bernhard Miklautz
94b35cb4f7 fix channel/smartcard: leak in Connect[AW]
smartcard_Connect[AW] leaked the reader buffer in error case.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
9fc754170b fix channel/smartcard: SCardStatus
Add support for fmszReaderNamesIsNULL. Formating of the touched files
was also updated.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
bc8bdc3e54 fix channel/smartcard: compiler warnings
* remove unused variables
* remove unused jump label
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
e3d45c4580 fix channel/smartcard: remove SCardAddReaderName
SCardAddReaderName isn't part of the SCard API.

Note: removing this also removes the possibility to redirect single
smartcard readers with /smartcard:READERNAME. However this features
wasn't implemented in a general way and will be re-added as part of
the smart card channel directly.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
1e6fea7fa7 fix channel/smartcard: simplify channel variables
Path was not really used and name was duplicated. Use the device->Name
directly.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
f8a3e7acd4 fix channel/smartcard: GetStatusChange return code
In case SCardGetStatusChange returned an error the call didn't return
any data but STATUS_NO_MEMORY as the calloc failed. This caused problems
with multiple applications server side (hangs and incorrect behavior).

Now the case when no readers are returned is handed correctly and the
data is also filled and send if the call fails.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
46a7538322 fix channel/smartcard: async request handling
The smart card channel tried to mimic mstsc's behavior on if an IRP was
processed synchronously or asynchronously. As the channel uses one thread per
context it could happen, especially with PCSC, that the main
channel thread was blocked waiting for an smart card operation to
complete. To prevent that behavior only call known safe functions in the
main thread (like CreateContext) and call the rest asynchronously.

For example the channel would block if a ListReaders is invoked on
the same context where a GetStatusChange (infinite timeout)
was already pending. Only when a status change happened the channel
would continue.

Note: Due to the one context per thread design it's important that
cancel isn't queued an alway run synchronously. Otherwise a specific
context might lock.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
3dc4e283db fix channel/smartcard: return value handling
Device control calls always returned SCARD_S_SUCCESS even if an error
occurred. This caused server side software (including the card manager)
to behave incorrectly.
2017-12-13 17:04:06 +01:00
Bernhard Miklautz
99c69cde27 fix channel/smartcard: error handling
According to MS-RDPESC the smart card channel must set the IoStatus to
an NTSTATUS in case a encoding or decoding error happens. The smart card
channel did this correctly but the output stream was modified
incorrectly causing the smart card remote manager to stop in error
cases.
2017-12-13 17:04:06 +01:00
Armin Novak
0490aeb018 Fixed clang malloc integer overflow warnings. 2017-07-20 09:29:48 +02:00
dodo040
03723c2738 fix wrong declaration 2017-07-19 13:16:08 +02:00
dodo040
722e927c64 redirect specific smartcard readers 2017-07-19 13:16:08 +02:00
Armin Novak
b2c29158be Scanbuild warning, argument checks and leak fixes.
* Added Stream_GetRemainingCapacity to check remaining stream size
  before writes.
* Fixed shadow server memory leak.
* Fixed lots of scanbuild warnings
* Added missing argument checks in many functions
* Added missing static function declarations
2017-03-02 18:13:43 +01:00
Armin Novak
ff56f75893 Fixed format specifier and unused variables. 2017-02-17 14:25:59 +01:00
Andreas Schultz
d2f98261f7 smartcard: implement ListReaderGroups
Conflicts:
	channels/smartcard/client/smartcard_operations.c
	channels/smartcard/client/smartcard_pack.c
	channels/smartcard/client/smartcard_pack.h

smartcard_operations: move handling of call argument into functions

The call argument was only use by static functions and was always equal
to operation->call. Remove the argument and use operation-call directly.

Also put the memory allocation and check into the same place.

Conflicts:
	channels/smartcard/client/smartcard_operations.c

Updated formatting and API
2017-02-16 16:59:03 +01:00
Norbert Federa
f71b6b46e8 fix string format specifiers
- fixed invalid, missing or additional arguments
- removed all type casts from arguments
- added missing (void*) typecasts for %p arguments
- use inttypes defines where appropriate
2016-12-16 13:48:43 +01:00
Norbert Federa
c6e6b44143 countless WLog/printf format specifier fixes 2016-11-25 17:06:25 +01:00
Marc-André Moreau
dee76617d9 channels: remove thread-local storage usage 2016-11-15 11:41:01 -05:00
Armin Novak
b0b32734ad Reformatted file. 2016-10-06 13:43:13 +02:00
Armin Novak
9f5da483dc Reformatted files touched in last 2 commits. 2016-10-06 13:43:12 +02:00
Armin Novak
88a3b8dd76 Initializing channel context in each thread. 2016-10-06 13:43:12 +02:00
David PHAM-VAN
d5dc5b4a3f Fix smartcard channel disconnect 2016-09-19 11:27:25 -07:00
Norbert Federa
ef4b29e5b3 ConvertFromUnicode fixes and misc hardening
- Added missing ConvertFromUnicode checks
- If ConvertToUnicode allocates memory, guarantee the null termination
  similar to ConvertFromUnicode's implementation
- Fixed some TestUnicodeConversion.c CTest return values
- Added some CTests for ConvertFromUnicode and ConvertToUnicode
- Misc code and protocol hardening fixes in the surrounding code regions
  that have been touched
2016-03-03 16:56:19 +01:00
Bernhard Miklautz
6fa3608111 cleanup cmake exports and pkg-config files
With this commit the "exported" components (usable with pkg-config and
cmake find module package)
* winpr - winpr library and headers
* freerdp - core library and headers
* freerdp-client - client specific library
* freerdp-server - server specific library
* rdtk - rdtk headers and library

To allow the installation of multiple different version (different major
number) the include files were moved into the respective sub folder:
freerdp -> freerdp{MAJOR}/freerdp (currently freerdp2/freerdp/)
winpr -> winpr{MAJOR}/winpr (currently winrp1/winpr/)
rdtk -> rdpk{MAJOR}/rdtk (currently rdtk0/rdtk/

The generated pkg-config and cmake find modules now also include the major
version number. Currently the following pkg-config are generated and
installed.
* winpr1
* freerdp2
* freerdp-server2
* freerdp-client2
* rdtk0

As cmake is able to handle multiple versions out of the box the
following can be used to find a specific module:

find_package(WinPR)
find_package(FreeRDP)
find_package(FreeRDP-Server)
find_package(FreeRDP-Client)
find_package(RdTk)

As cmake doesn't automatically resolve dependencies for packages it is
necessary to manually include the requirements. For example if
FreeRDP-Client is required WinPR and FreeRDP need to be included
(find_package) as well.

This commit also fixes the installation when STATIC_CHANNELS are built.
WITH STATIC_CHANNELS all channels are linked into libfreerdp-client, for
this all channels are generated as linker archive and linked together in
the final step. Before the intermediate linker archives were, although
not required and useful, installed. Same applies for server side
channels.
2016-01-12 17:32:33 +01:00
Armin Novak
cb958ba9c6 Added pdb files to package target.
Fixed name collision with freerdp-shadow targets.
2015-12-15 12:07:21 +01:00
bjcollins
456416a871 Dont use invalid/bogus input value for cbAtrLen for Smartcard Status Calls, instead just always use the max value here to indicate we have max
buffer space available.
2015-09-18 16:55:06 -05:00
Armin Novak
911750f0f6 Checking for allocation value > 0 2015-09-07 11:10:27 +02:00
Armin Novak
97f7aa8f42 Fixed uninitialized values. 2015-09-01 12:27:54 +02:00
Armin Novak
aa43f3b5df Fixed zero lenght allocation. 2015-09-01 12:25:44 +02:00
Marc-André Moreau
90b7d42429 Merge pull request #2838 from akallabeth/smartcard_no_readers
Added return value checks for smartcard functions.
2015-08-27 10:05:23 -04:00
Martin Haimberger
52405a3e79 Remove WIN32ERROR type
All return values are UINT now.
2015-08-27 05:38:20 -07:00
Armin Novak
c40f3198a4 Added return value checks. 2015-08-19 12:50:48 +02:00
Martin Haimberger
2862109337 Merge remote-tracking branch 'upstream/master' into mh-channel-fix
Conflicts:
	channels/smartcard/client/smartcard_main.c
	channels/smartcard/client/smartcard_operations.c
2015-07-30 07:29:12 -07:00
Martin Haimberger
65fd259610 misc fixes:
fixed all bugs from the review
checking all WaitFor*Object/s calls
2015-07-30 06:49:21 -07:00
Marc-André Moreau
dfa29804ad Merge pull request #2799 from kaliway/scardlistreaders-fix
Smartcard Reader Connection Handling
2015-07-28 08:51:03 -04:00
Kirill Kotyagin
ef37487a44 channels/smartcard: fix possible mszReaders leak in smartcard_ListReaders(A/W)_Call 2015-07-22 17:25:17 +03:00
Kirill Kotyagin
76916d614b channels/smartcard: make smartcard_ListReaders(A/W)_Call return PCSC error statuses to the server 2015-07-22 16:56:24 +03:00
Rostislav Kondratenko
7248ea98d0 Fixing condition on SCardIsValidContext to be true when context is valid 2015-07-17 18:13:02 +03:00
Rostislav Kondratenko
f2863fabf5 Re-enabled PCSC-Lite transactions and fixed smartcard deinitialization so it will release all contexts to unblock calls waiting for transactions 2015-07-17 16:37:44 +03:00
Martin Haimberger
b8c110d19b introduced channel error reporting system
The rdpContext gets an event which will
get set if an error occoured in a channel.

If a thread or a void callback has to report an
error it will get signaled by this system.
2015-07-15 00:50:35 -07:00
Martin Haimberger
d9e2834a70 channel smartcard hardend 2015-07-09 03:00:19 -07:00
Martin Haimberger
6e4e1c2773 Merge remote-tracking branch 'upstream/master' into mh-stream-fix
Conflicts:
	client/Windows/wf_cliprdr.c
2015-06-18 03:06:40 -07:00
Martin Haimberger
76305a716c just satisfied compiler 2015-06-18 03:04:33 -07:00