Commit Graph

520 Commits

Author SHA1 Message Date
matt335672 ace386d072 clipboard: Allow a file read to return 0 for EOF
When used with a FreeRDP client on Linux, a file copy operation from
the clipboard detects end-of-file by a read returning 0 bytes. This is
currently marked as an error.

It is assumed that mstsc.exe detects end-of-file in another way, which
is why this has not been found before.

(cherry picked from commit 0f6e731524)
2024-08-05 09:54:37 +01:00
matt335672 e59dc16be6 Remove unnecessary copy from clipboard_get_files()
The routine clipboard_get_files() parses a potentially long string,
and copies portions of it into a temporary buffer. This buffer is then
passed to clipboard_get_file() as pointer + length;

The buffer is inadequately sized for very long filenames which may
approach XFS_MAXFILENAMELEN in length. This can cause chansrv to fail
when the user copies such filenames.

It turns out the buffer is unnecessary, as the filenames can be
passed directly into clipboard_get_file() from the source string,
using pointer + length. This avoids the length limitation entirely.

(cherry picked from commit 34b5582460)
2024-08-05 09:54:26 +01:00
matt335672 f3070aef15 Allow for longer filenames from the redirector.
This commit ensures that filenames up to the maximum size supported
by our xfs can be supported.

(cherry picked from commit c3f7eec4f5)
2024-08-05 09:54:07 +01:00
matt335672 6c9d56efc2 Remove hard-coded filename limit for clipboard file lists
The limit of 256 characters for clipboard files is limiting for
many Asian locales, particularly as '%xx' notation is used to
communicate bytes with bit 7 set.

(cherry picked from commit a90228241d)
2024-08-05 09:53:55 +01:00
matt335672 f4153a493d Dynamically allocate XFS filesystem names
Replace the 256 byte buffer used for names in the XFS filesystem with a
dynamically allocated buffer.

The define XFS_MAXFILENAMELEN which used to be 255 has been retained,
but bumped to 1023. This value is no longer used for long-lived
allocations, but is used in chansrv_fuse.c for maintaining state
information for in-fligh I/O requests.

(cherry picked from commit d8b5435710)
2024-08-05 09:53:44 +01:00
matt335672 5223672437 Fix potential name buffer overflows in redirector
The state buffers used by the following structs in chansrv_fuse.c
are one byte too small for filenames of length XFS_MAXFILENAMELEN:-
- struct state_lookup
- struct state_create
- struct state_rename

In practice, there is no runtime danger, as XFS_MAXFILENAMELEN is 255,
and these buffers will be followed by non-byte aligned data. Nevertheless
this should be fixed to prevent problems if the value is changed.

(cherry picked from commit c9e84dc16c)
2024-07-23 12:29:43 +01:00
Koichiro Iwao e070902310
clipboard: tidy up bmp file header assembly
Sponsored by:   Krämer Pferdesport GmbH & Co KG
2024-06-18 11:13:40 +09:00
Koichiro Iwao 4968a34cd6
clipboard: fix a bug when pasting image to LibreOffice
While here, embed correct file size in BMP file header.

Fixes:          #3102
Sponsored by:   Krämer Pferdesport GmbH & Co KG
2024-06-17 21:08:30 +09:00
matt335672 dcaa31ef16 chansrv FUSE fixes
1) [Regression] If the specified mountpoint is not immediately below an
   existing directory, the directory is not created.
2) The message to ask the user to unmount an existing mounted directory
   has been moved to the right place.

(cherry picked from commit e0a1339b34)
2024-05-22 09:55:01 +01:00
metalefty 45fd497645
Merge pull request #2891 from neutrinolabs/gfx_mainline_merge_work
Gfx mainline merge work
2024-02-08 21:50:16 +09:00
Koichiro Iwao 47d4ab1339 Apply astyle 3.4 code formatter 2024-02-08 15:52:54 +09:00
Nexarian 584a894490 Add 0 as valid g_obj_wait timeout instead of having it be equivalent to -1. 2024-01-31 19:08:29 -05:00
matt335672 50cff2eb75
Merge pull request #2794 from matt335672/utf_changes_new
Improve Unicode support
2023-11-02 10:57:39 +00:00
matt335672 76d12c50a8
Merge pull request #2838 from matt335672/fix_devredir_ordering
Fix message ordering in devredir
2023-10-26 15:28:10 +01:00
matt335672 7ceff70c1c Fix message ordering in devredir
The drive redirector is not compliant with the message ordering
in [MS-RDPEFS], causing FreeRDP 2.11.2 ro fail on redirecting drives.
2023-10-26 15:17:17 +01:00
matt335672 675dd77807 Parameterise the sockdir with the UID of the user
The top level socket directory is now called XRDP_SOCKET_ROOT_PATH.
Below that are user-specific directories referred to with the
XRDP_SOCKET_PATH macro - this name is hard-coded into xorgxrdp and
the audio modules as an environment variable.

XRDP_SOCKET_PATH now looks like $XRDP_SOCKET_ROOT_PATH/<uid>

XRDP_SOCKET_PATH is only writeable by the user, and readable by the user
and the xrdp process.
2023-10-23 18:14:46 +01:00
matt335672 d722ffe357 Update smartcard code to use new UTF-8 calls 2023-10-23 14:19:49 +01:00
matt335672 1b286a0469 Update RAIL code to use new UTF-8 calls 2023-10-23 14:19:49 +01:00
matt335672 8556f83905 Update drive redirection code to use new UTF-8 calls 2023-10-23 14:19:49 +01:00
matt335672 f8e7fd4c2c Update clipboard code to use new UTF-8 calls 2023-10-23 14:15:47 +01:00
firewave f687174af1 provide more includes to Cppcheck
- added (temporary) suppression of Cppcheck `shiftTooManyBits` false positives in `libxrdp/xrdp_mppc_enc.c`
- added (temporary) suppression of Cppcheck `uninitMemberVar` true positives in `ulalaca/ulalaca.cpp` until fixes land downstream
- fix Cppcheck `nullPointerRedundantCheck` in `sesman/chansrv/clipboard.c`
- fix Cppcheck `syntaxError` in `fontutils/mkfv1.c` because it doesn't see the `freetype/fterrors.h` header / removed astyle workaround
2023-10-17 15:14:36 +02:00
matt335672 2a287963da devredir_proc_query_dir_response(): Conform to spec
This commit adds more error checking to the above function. The function
now conforms to [MS-FSCC] regarding processing of the NextEntryOffset
field.
2023-10-16 10:28:41 +01:00
matt335672 284c17c0b2 Remove client-server shortcut paste code
When significant amounts of data is coming from the client in a
fragmented CLIPRDR_DATA_RESPONSE PDU, this code provides a way to
start copying it to a requesting client before it is all read.

The only advantage of this code is to provide a slight speedup
before a paste is visible on the server.

There are significant problems with this code. Notably, it is
very difficult to parse Unicode text coming through this route. Each
UTF-16 character can occupy up to 4 bytes, and a fragmentation
boundary could occur at any point within a UTF-16 character.
2023-09-29 12:07:19 +01:00
matt335672 e138c1a601 Update comments in smartcard code
Most of the Microsoft RDP documentation describes PDUs on-the-wire.
However, [MS-RDPESC] doesn't do this. It uses DCE IDL to describe the
contents of the PDUs sent over the File System Virtual Channel.

Ideally we'd use an IDL compiler to generate the interfaces in
[MS-RDPESC]. We don't have one though, so all PDUs are read and written
with the low-level streaming routines. It's not clear in the existing
code how IDL is mapped down to this level.

This commit updates the smartcard code with comments which will enable
maintainers to better understand the IDL-to-streaming mappings.
2023-09-25 16:13:00 +01:00
firewave 27d34e784d fixed Cppcheck `unusedVariable` warnings 2023-09-04 23:47:56 +02:00
matt335672 84ae372a58 clipboard: Fix TODO action in clipboard_common.h
Use the official Windows clipboard format names where appropriate

Replace g_file_format_id with g_file_group_descriptor_format_id
as the latter name is more descriptive of what is described in
[MS-ECLIP]
2023-08-07 15:11:04 +01:00
matt335672 8eed7a395e clipboard: Only advertise text to X11 clients if it is available 2023-08-07 15:11:04 +01:00
matt335672 45ca9fe098 clipboard: Tell the X11 client if a selection is unavailable 2023-08-07 14:45:11 +01:00
matt335672 7cf9101407 Fix compile errors detected by the older gcc 4.8.5 compiler:-
sesexec.c: In function ‘main’:
sesexec.c:521:1: error: control reaches end of non-void function [-Werror=return-type]

sound.c: In function ‘process_pcm_message’:
sound.c:1123:21: error: ‘for’ loop initial declarations are only allowed in C99 mode
                     for (int i = 0; i < send_silence_times; i++)
                     ^
sound.c:1123:21: note: use option -std=c99 or -std=gnu99 to compile your code

These fixes are in line with our coding standard and have no functional change.
2023-06-07 20:21:54 +01:00
matt335672 05d1733950 Change chansrv to use common fifo code 2023-05-22 14:43:22 +01:00
matt335672 8535f8e08c
Merge pull request #2675 from matt335672/fix_chansrv_signal_handling
Fix signal handling in chansrv.c
2023-05-22 10:03:02 +01:00
Daniel Richard G 1c0c923ad1 Split g_file_open() into _ro() and _rw() variants
Rename g_file_open() to g_file_open_rw(), and add a new g_file_open_ro()
call that wraps the common g_file_open_ex(file, 1, 0, 0, 0) idiom. This
will make the file access mode more explicit in the code.

Change all calls to g_file_open() to the _ro() or _rw() variant as
appropriate, and replace g_file_open_ex(file, 1, 0, 0, 0) with the _ro()
call.

Lastly, add tests for the two new calls to test_os_calls.c (code
courteously provided by matt335672).
2023-05-15 17:38:31 -04:00
matt335672 0a44594f51 Fix signal handling in chansrv.c
Signal handlers now only use signal-safe code

See signal-safety(7) on Linux
2023-05-15 14:16:29 +01:00
Daniel Richard G 42d32e7496 Use config_ac.h consistently and correctly 2023-05-12 13:49:53 -04:00
Jay Sorg 6628d57b55 chansrv: build fix, use libipm from build dir 2023-04-03 22:25:06 -07:00
matt335672 ea12231247 Updaste chansrv files related to new libsesman 2023-03-30 13:07:49 +01:00
matt335672 2f3693b3dc autotools changes related to new libsesman library 2023-03-29 14:31:30 +01:00
matt335672 177707dcb9
Merge pull request #2608 from Hiero32/Support-to-set-parameters-for-#2519
Support to set parameters for #2519
2023-03-29 10:29:23 +01:00
Hiero32 9fe9ae3bc0 Support to set parameters from sesman.ini. 2023-03-28 21:20:54 +09:00
matt335672 3ee8eb9c9e
Merge pull request #2592 from matt335672/restructure_session_start
Restructure session start
2023-03-27 10:38:37 +01:00
Jay Sorg 054c78d568 chansrv: don't free item on stack 2023-03-24 16:33:16 -07:00
matt335672 8b9f9b40c8 os_calls changes
- Add g_pipe()
- Add g_file_duplicate_on()
- Rework struct exit_status to make it easier to parse
- Add optional status return to g_waitchild()
2023-03-23 18:12:06 +00:00
Zhipeng Xue fbb3b9cef9 Fix potential null dereference 2023-03-05 13:38:43 +08:00
matt335672 acdfd12cb6 Fix typo in chansrv_fuse.c
The code as it stands is checking two file descriptors for possible
input, but only one needs to be checked.
2023-02-13 14:28:29 +00:00
matt335672 78fa1c15b2 Replace select() system call with poll()
poll() is specified in POSIX.1-2001 as a simpler interface for
multiplexed file descriptors than select(). It also provides more
functionality.

This PR replaces the select() calls used in xrdp with poll()
equivalents.
2023-02-13 14:28:29 +00:00
metalefty f3dc94448c
Merge pull request #2537 from metalefty/sound-log
sound: logging improvements
2023-02-13 10:38:31 +09:00
Koichiro IWAO 9d7a817e87 chansrv/audin: return UNKNOWN when undefined value
is passed to audin_wave_format_tag_to_str.
2023-02-11 11:51:08 +09:00
Hiero32 1ffe7890d8
sound: fix noise between two playbacks for mp3/aac (#2519)
* sound: fix noise between two playbacks for mp3/aac
* fix sound stuttered on skip operation of vlc
2023-02-09 10:09:04 +09:00
Koichiro IWAO 73a8865561 chansrv/audin,sound: record index of formats array
It helps to know which audio format is in use.
2023-02-09 01:21:45 +09:00
Koichiro IWAO a355b7bf98 chansrv/audin: record audin (microphone redirection) audio formats 2023-02-09 01:06:44 +09:00