Commit Graph

980 Commits

Author SHA1 Message Date
Bernhard Miklautz 421b74e85e client/locale: properly check popen return value
popen returns NULL if an error occurs and not < 0.
2015-06-22 19:23:58 +02:00
David FORT 7c3f8f33ab Fixes for malloc / calloc + other fixes
This patch contains:

* checks for malloc return value + treat callers;
* modified malloc() + ZeroMemory() to calloc();
* misc fixes of micro errors seen during the code audit:
** some invalid checks in gcc.c, also there were some possible
integer overflow. This is interesting because at the end the data are parsed
and freed directly, so it's a vulnerability in some kind of dead code (at least
useless);
** fixed usage of GetComputerNameExA with just one call, when 2 were used
in misc places. According to MSDN GetComputerNameA() is supposed to return
an error when called with NULL;
** there were a bug in the command line parsing of shadow;
** in freerdp_dynamic_channel_collection_add() the size of array was multiplied
by 4 instead of 2 on resize
2015-06-22 19:21:47 +02:00
Bernhard Miklautz d9d1759abc Fix compiler warnings:
gcc 4.7.2

client/X11/xf_keyboard.c: In function ‘xf_keyboard_action_script_init’:
client/X11/xf_keyboard.c:48:6: warning: unused variable ‘exitCode’
[-Wunused-variable]

gcc 4.9

client/X11/xf_client.c: In function ‘xf_client_thread’:
client/X11/xf_client.c:1537:3: warning: ‘inputThread’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
2015-06-22 19:09:59 +02:00
Bernhard Miklautz bf73f4e4f1 Fix unchecked strdups
* add missing checks
* adapt function return values where necessary
* add initial test for settings
2015-06-22 19:09:59 +02:00
Norbert Federa f04bb6c53d xfreerdp: xfc->palette wasn't updated with /gdi:sw
When using software gdi (/gdi:sw) the rdp update PDU callback
gdi_palette_update() is used which writes the new colors to
the rdpContext's gdi->palette buffer.
The X11 functions however access xfc->palette which gets only
updated by xf_gdi_palette_update() which is the callback if
/gdi:hw is used.

This commit changes xfc->palette to a pointer which points to
xfc's private buffer with /gdi:hw or to the gdi->palette if
software gdi is used.
2015-06-11 18:40:41 +02:00
Hardening 29de9b6d4e Merge pull request #2658 from hardening/fix_2657
Fix for #2657
2015-05-29 17:58:30 +02:00
David FORT 12f873f1f9 Fixed MessageQueue and callers 2015-05-29 14:24:14 +02:00
David FORT 85c350f5da Fix for #2657 2015-05-27 15:13:43 +02:00
Marc-André Moreau b9c1cddc2e Merge pull request #2583 from bceverly/OpenBSD-cleanup
Two minor source code changes to remove warnings
2015-05-21 10:17:54 -04:00
Norbert Federa cd0a8e0506 Merge pull request #2630 from hardening/new_2616
Add checks for some XXX_New and XXX_Add functions
2015-05-21 16:04:26 +02:00
David FORT b83af4c059 Fixed declaration of xf_event_action_script_init() 2015-05-20 21:01:46 +02:00
David FORT 29d372480a Take in account nfedera's review 2015-05-20 19:19:50 +02:00
Norbert Federa 4d661fdb35 client/x11: fix + simplify invalidate_poly_region 2015-05-19 01:13:40 +02:00
Hardening f8120919af Add checks for some XXX_New and XXX_Add functions
Based on PR #2616
2015-05-18 11:28:00 +02:00
Norbert Federa 1b5abec683 client/x11: fixed if statements with empty body 2015-05-17 18:24:11 +02:00
MartinHaimberger e3236c2317 Merge pull request #2605 from nfedera/fix-2015-05-08-01
fixed multiple missing gdi return value checks
2015-05-11 16:59:32 +02:00
Norbert Federa 1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Norbert Federa 71a4349928 fixed multiple missing gdi return value checks
mainly gdi_Create* functions
2015-05-08 21:39:23 +02:00
David FORT 0e2925d0b8 Fix remoteApps
The assert that have been removed were preventing RAIL from working when you
have an intermediary screen before seeing the application.
2015-05-07 14:36:07 +02:00
Norbert Federa 25fc866a58 Fix unchecked CreateThread calls and misc fixes 2015-05-05 13:55:48 +02:00
Bryan Everly df9ae5e31b Changed the xf_tsmf.c code to test for zero visible rectangles for all platforms. Modified arc4random() change to actually have a skeletal implementation in winpr for BCryptGenRandom() on all platforms. 2015-04-30 10:12:37 -04:00
Norbert Federa ef1fd12b15 Fix unchecked CreateEvent calls and misc fixes
1)
Added missing checks for CreateEvent which also required the
following related changes:

- changed freerdp_context_new API to BOOL
- changed freerdp_peer_context_new API to BOOL
- changed pRdpClientNew callback to BOOL
- changed pContextNew callback to BOOL
- changed psPeerAccepted callback to BOOL
- changed psPeerContextNew callback to BOOL

2)
Fixed lots of missing alloc and error checks in the
changed code's neighbourhood.

3)
Check freerdp_client_codecs_prepare result to avoid segfaults
caused by using non-initialized codecs.

4)
Fixed deadlocks in x11 caused by missing xf_unlock_x11() calls
in some error handlers

5)
Some fixes in thread pool:
- DEFAULT_POOL assignment did not match TP_POOL definition
- don't free the pool pointer if it points to the static DEFAULT_POOL
- added error handling and cleanup in InitializeThreadpool
2015-04-29 18:18:39 +02:00
Bryan Everly 6ed90e831e Fixed linker warning about insecure crypto and fixed compiler warning about unsigned being compared to less than zero 2015-04-28 10:50:29 -04:00
Marc-André Moreau 1fea6bf702 Merge pull request #2568 from nfedera/fix-2015-04-23-01
codec/rfx: error checking and various fixes
2015-04-24 13:36:27 -04:00
Bryan Everly 18b335e2f2 Added support for manpage construction for OpenBSD 2015-04-24 08:38:35 -04:00
Norbert Federa 84577b1ca7 codec/rfx: error checking and various fixes
- removed some unneeded null checks for free()
- fixed a memory leak in shadow_client
- removed rfx_compose_message_header from API

Changed the following functions to BOOL, check the result
where they are called and handle failures:
- rfx_compose_message
- rfx_compose_message_header
- rfx_write_tile
- rfx_write_message_tileset
- rfx_write_message_frame_begin
- rfx_write_message_region
- rfx_write_message_frame_end
- rfx_write_message

rfx_process_message:
- check memory allocation failures
- verify protocol-conform order of data messages to prevents memory
  leaks caused by repeated allocations
- verify that header messages were parsed/received before the
  data messages
- treat unknown rlgr mode as error
- fixed/added error handling
- fixed all callers to check/handle result

rfx_encode_message:
- fixed incorrect usage of realloc
- missing malloc check
- missing check of CreateThreadpoolWork
- correct cleanup on failure (threadpool, memory)
- check rfx_encode_message result

rfx_encode_messages:
- check rfx_split_message result
- correct cleanup on failure
- prevent memory leak on failure

rfx_write_message_context:
- fixed invalid channelId value (must be 0xFF for WBT_CONTEXT)

rfx_process_message_codec_versions:
- fixed invalid read size of codec_version (it is 16bit)

rfx_process_message_channels:
- verify protocol conform channelId value

rfx_process_message_region:
- replaced invalid reallocs with malloc
- read and verify regionType and numTileSets from stream

rfx_process_message_tileset:
- check allocation results
- fixed incorrect usages of realloc

setupWorkers:
- fixed incorrect usages of realloc

rfx_split_message:
- removed dead code
- missing malloc check

rfx_compose_message:
- fixed a memory leak
- check/handle rfx_encode_message result
2015-04-23 15:42:21 +02:00
Hardening 6cd7713e12 Merge pull request #2544 from bmiklautz/boolenization
change return types of callbacks to BOOL
2015-04-22 11:01:27 +02:00
Bryan Everly 8c75127a67 Necessary changes to get latest branch working on OpenBSD 5.6 2015-04-21 14:42:06 -04:00
Bernhard Miklautz 1e6943bf31 Fix formating 2015-04-21 14:20:24 +02:00
Bernhard Miklautz db81151ea4 gdi: fix broken return type checks
Integrates comments from pull request.
2015-04-21 14:18:07 +02:00
Bernhard Miklautz 2c072d33d3 Fix GDI return values and other fixes
* top level GDI functions return 0 on error and != 0 otherwise but the
  low level functions (16bpp.c, 8bpp.c 32bpp.c) which are called did it
	exactly the other way around. Those were adapted.
* change gdi_InvalidateRegion to BOOL and check calls where appropriate
* integrate comments from pull request
2015-04-21 14:18:07 +02:00
Bernhard Miklautz 515502ffa5 change return types of callbacks to BOOL
* change all client/server callbacks to BOOL
* update all clients accordingly
* add multiple return value checks
* small fixes
2015-04-21 14:18:07 +02:00
Armin Novak d3336340ba Add *get_event_handles handle count, return check. 2015-04-21 12:24:50 +02:00
Norbert Federa fd5f47428b xfreerdp: fixed initial smart-sizing dimensions
The window width/height variables and in turn SmartSizingWidth/Height
get automatically updated in th the configure notify event handler.
If the window is created initially the values don't differ from the
event values and therefore SmartSizing was not applied until the
window was resized.
2015-04-16 23:54:56 +02:00
Norbert Federa bad2f138c1 xfreerdp: FS fixes & smart-sizing resuscitation
- make smart-sizing work again which was killed in previous commits
- removed several unnecessary/ugly workarounds
- miscellaneous small fixes
- new feature: restore previous window position when toggling out of
  fullscreen mode
- new feature: if /f is specified in combination with /smart-sizing:WxH
  we run the session in the /smart-sizing dimensions scaled to full screen
2015-04-16 17:31:22 +02:00
Norbert Federa eb14ab15f5 xfreerdp: removed some weird/unnecessary code 2015-04-16 17:31:22 +02:00
Norbert Federa 98505a0234 xfreerdp: removed desktopWidth/desktopHeight vars
These were basically unused (from the contexts's point of view)
and only served as temporary storage
2015-04-16 17:31:22 +02:00
Norbert Federa b3b8306724 xfreerdp: removed unused variables from xf_monitor 2015-04-16 17:31:22 +02:00
Norbert Federa 6354a7561c xfreerdp: rename xf_context's width height vars
Since several contributers in the past repeatedly made the error
to treat xfc->width and xfc->height as equal with the x11 window
width and heigth I've renamed these variables to sessionWidth and
sessionHeight.
2015-04-16 17:31:22 +02:00
Bernhard Miklautz 3c7662517c hardening
Start to add missing checks for:
* *alloc
* *_New
2015-03-25 17:38:21 +01:00
Armin Novak c380fb3520 Added flag to ignore unknown keywords
freerdp_client_settings_parse_command_line now allows ignoring
unknown keywords.
2015-03-16 10:15:37 +01:00
Marc-André Moreau 5ab34dfa3e Merge pull request #2456 from zhangzl2013/fix-realloc
Fix incorrect usage of realloc
2015-03-12 07:33:27 -04:00
Marc-André Moreau 719a0fd3e9 Merge pull request #2426 from bjcollins/master
xfreerdp fullscreen enhancements
2015-03-12 07:27:29 -04:00
Zhang Zhaolong 855b1201aa xf_cliprdr: fix incorrect usage of realloc.
Signed-off-by: Zhang Zhaolong <zhangzl2013@126.com>
2015-03-11 12:31:50 +08:00
Seray Rosh ffa7f0363f release keys when xfreerdp is unfocused to prevent stuck keys 2015-02-27 16:02:40 +01:00
bjcollins d4a9a2d3a8 Remove override redirect flag for fullscreen with keyboard grab enabled. Window manager should always know about the main window.
Small cleanup of passing around decorations flag.
Limit PercentScreen to single monitor vs. entire desktop. IMO - this is better behavior in a multimonitor environment.

Handle fullscreen windows better:
1. Ensure that size hints are set to allow resizing before setting a window to fullscreen as some window managers do not behave properly.
2. Handle fullscreen toggles without destroying and recreating window.
3. Use NET_WM_STATE_FULLSCREEN Extended Window Manager Hint for fullscreen functionality
4. Use the NET_WM_FULLSCREEN_MONITORS Extended Window Manager Hint when appropriate
5. When a single monitor fullscreen is requested - use the current monitor(as determined from mouse location)
6. Handle cases where there is no local monitor at coordinate 0,0. The Windows server expect there to be a monitor at this location, so we maintain offset if necessary between our local primary monitor and the server side primary monitor located at 0,0.
2015-02-23 11:22:28 -06:00
Marc-André Moreau 991f7b347d libfreerdp-core: further abstract multiple connections used internally by tsg from rdpTransport 2015-02-15 10:06:17 -05:00
bjcollins ee8d0a6440 Fix remote app in xfreerdp.
Remove use of the visibleOffset, this completely breaks the display of all windows except for the main application window. Instead,
just maintain a local offset correction of the windowOffset.

Apply workaround to determining the workArea for remote app mode.
2015-02-11 17:24:06 -06:00
Marc-André Moreau 22ac46957a xfreerdp: fix egfx multimonitor support 2015-02-10 16:32:07 -05:00
Marc-André Moreau 9b9fbd2ab1 xfreerdp: fix fullscreen mode 2015-02-10 15:15:30 -05:00