Commit Graph

567 Commits

Author SHA1 Message Date
matt335672 8099299ab0 Allow for empty UTF8_STRING to be pasted
The current code doesn't allow for an empty string to be pasted to the
clipboard on the X11 side.  This is done by some lock screen programs
to prevent information leakage.
2025-08-04 11:25:54 +01:00
matt335672 539eb33795 Prevent possible double-free on chansrv exit 2025-06-21 14:38:06 +01:00
matt335672 554515e39c Refactor static channel name handling
1) Remove 'magic numbers' related to static channel name lengths, and
   replace with CHANNEL_NAME_LEN, or CHANNEL_NAME_LEN+1, as appropriate.
2) Always add static channel definitions, even if they are malformed.
3) Log channels which the client sends, which aren't named in
   the [Channels] section of xrdp.ini.

(cherry picked from commit 9092d898b7dceda713bd05b296ea8e8213ee614b)
2025-04-26 17:06:10 +01:00
matt335672 343e84a76a Remove SIGTERM race in chansrv
The signal handlers for SIGTERM are put in place before the
sigterm object is created. If a SIGTERM is received between the
two, it is ignored and chansrv will not exit.
2025-03-29 17:15:45 +00:00
matt335672 8b449868fe Coverity CID 468108
Repeated constant WAVE_FORMAT_MULAW in conditional
2025-02-28 14:34:26 +00:00
matt335672 2f46ef27a2 Add support for cppcheck 2.17.0
cppcheck 2.17.0 adds checks that a NULL pointer returned from malloc() and
calloc() is not used.

We do this quite a lot.

I've addressed this by adding functions g_malloc_nofail() and
g_calloc_nofail() which either allocate memory or abort.
functions are now called in places where we are not making these
checks.

Many of these checks are in test programs or example programs.

I've modified the list16 module to handle out-of-memory conditions.
2025-02-27 15:04:11 +00:00
matt335672 cb90458609 Coverity CID 468116 2025-02-10 15:31:19 +00:00
matt335672 6088ba3f3b Address offline Coverity issue
This Coverity issue was encountered in a private build, but does not
appear to be in the Github CI build. Coverity is suspecting a copy-paste
betweem these lines in sound.c:-

1838: xstream_copyin(s, &g_stream_inp->data[g_stream_inp->size - g_bytes_in_stream], i);
1844: xstream_copyin(s, &g_stream_inp->data[g_stream_inp->size - g_bytes_in_stream], g_bytes_in_stream);

An inspection of the code shows this to bre a false positive
2025-02-10 15:26:55 +00:00
matt335672 eff8ba75ee Coverity CID 468140 2025-02-03 15:32:55 +00:00
matt335672 db32f9c6a3 Coverity CID 468119
Add additional check to prevent Coverity assuming the worst
2025-02-03 15:32:55 +00:00
matt335672 201cdc1aea Fix coverity warning over mem leak in smartcard code 2025-01-24 11:36:40 +00:00
matt335672 b04743066d Fix coverity-reported issues
The errors in sesman/chansrv/chansrv_fuse.c appear to be false positives
caused by allocating xhandle->dir_handle, and then
casting xhandle to an integer in xfuse_handle_to_fuse_handle(), thus
hiding xhandle->dir_handle

For both occurrences, the logic has been simplified and made the same,
and a comment has been added to suppress the error.
2025-01-13 10:27:29 +00:00
Constantin Kulikov 151c555fc0 Add sesman.ini FuseMountNameColonCharReplacement option 2025-01-08 16:23:14 +03:00
matt335672 e3d502ca06 Merge pull request #3328 from matt335672/fix_time_calls
Remove/replace time calls
2025-01-06 10:22:40 +00:00
Koichiro Iwao 75736f4853 Allow to change config file (sub)directory
This allows the `xrdp` part of the path `/etc/xrdp` where config files
are placed to be customizable. This change is useful when trying the
stable version and the devel version alternately.
2024-12-27 10:53:31 +09:00
matt335672 1f79eb1c01 Replace g_time3() with g_get_elapsed_ms()
The function as specified used gettimeofday() which is susceptible
to manual time changes, and is obsoleted in POSIX.1-2008. The
replacement uses clock_gettime(CLOCK_MONOTONIC, ) which is not
susceptible to manual time changes (at least on Linux) and cannot run
backwards.

Also, on systems with 32-bit integers, the value returned by this
function wraps around every 49.7 days. To cope with a wraparound in
a way compliant with the C standard, this value needs to return an
unsigned integer type rather than a signed integer type.
2024-12-16 16:13:15 +00:00
matt335672 90798cdeaa Remove g_time2() call
This is currently unused in xrdp
2024-12-16 16:13:15 +00:00
matt335672 b02689ab44 Remove g_time1() call
This is not year 2038 compliant on systems with 32-bit integers.

The call can be replaced with the standard C time() call. On
POSIX systems, time_t is guaranteed to be an integer type.
2024-12-16 16:13:15 +00:00
matt335672 162153ab6f Move LogFilePath parameter to [ChansrvLogging]
This seems a better fit than having it in the [Chansrv] section.

Also fixed a minor logging error relating to the parameter in
chansrv_config.c

(cherry picked from commit 6d2fd1be8451418f01dfbb203929e2838c1a979f)
2024-12-16 10:55:30 +00:00
matt335672 2f7be3f634 Allow a path to be specified for the chansrv log
This is useful for NFS-mounted home directories, where hosts
may otherwise produce colliding chansrv log file names

(cherry picked from commit cfc2e362b47103bc2c786252f331bb26b6ddecb5)
2024-12-16 10:55:21 +00:00
matt335672 6a49ff9946 Add fix for chromium saving files to FUSE filesys
Chromium 130 won't save to our filesystem if we don't return a
max filename length.

Dummy parameters were tried for inode counts, but these do not seem to
be necessary. Not also that btrfs foes not return values for these
fields.
2024-11-11 12:15:23 +00:00
matt335672 5dc4fdbc2c Add support for statvfs() to FUSE
Some desktop environments are now checking for free space before
copying files to a destination.

To support this, the FUSE filesystem needs to convert the statvfs()
system call to the relevent PDUs from [MS-RDPEFS]
2024-11-08 15:57:40 +00:00
matt335672 514c62c7c1 Merge pull request #3275 from matt335672/move_to_fuse3
Move to fuse3
2024-10-23 10:12:35 +01:00
matt335672 c46eece00f Add support for creating sockdir to chansrv
Chansrv now checks for the user sockdir being present. If it
isn't, it connects to chansrv and requests it be created.

This also needs the sesman port to be added to the chansrv
config struct.
2024-10-22 12:21:25 +01:00
matt335672 b5772cef91 Only use fuse_set_log_func() for libfuse >= 3.7 2024-10-21 16:55:24 +01:00
matt335672 edd4276633 Migrate chansrv to FUSE3 interface 2024-10-15 11:44:16 +01:00
matt335672 b9703af7ee Pick up correct includes/libraries for FUSE3 2024-10-14 16:44:09 +01:00
Bob Carroll 89a4a1b8f7 update man page and fix code style issue 2024-09-24 18:03:40 -07:00
Bob Carroll 66e5eebb1c add option to enable FUSE direct i/o on file open 2024-09-20 20:23:47 -07:00
matt335672 0f6e731524 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.
2024-08-02 12:41:20 +01:00
matt335672 34b5582460 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.
2024-08-02 12:41:20 +01:00
matt335672 c3f7eec4f5 Allow for longer filenames from the redirector.
This commit ensures that filenames up to the maximum size supported
by our xfs can be supported.
2024-08-02 12:41:20 +01:00
matt335672 a90228241d 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.
2024-08-02 12:41:20 +01:00
matt335672 d8b5435710 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.
2024-08-02 12:41:20 +01:00
matt335672 c9e84dc16c 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.
2024-07-22 14:44:58 +01:00
Koichiro Iwao a6199e8510 clipboard: tidy up bmp file header assembly
Sponsored by:   Krämer Pferdesport GmbH & Co KG

(cherry picked from commit e070902310a46c0fd9b47e3e6c24f0d3bfcb05b7)
2024-06-18 21:56:30 +09:00
Koichiro Iwao 57cf5c19b7 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

(cherry picked from commit 4968a34cd62fe740abc612c581e6faa705f12bd1)
2024-06-18 21:56:19 +09:00
matt335672 5f91eec695 Remove duplicate enable&disable func registration 2024-05-30 12:19:20 +01:00
matt335672 f0069456f9 Remove the wait for the ibus daemon to start
The initial implementation of Uinicode input via IBus used a startup delay
of 3 seconds to wait for the daemon to be ready before connecting to it.

This commit introduces a poll-wait loop which can remove the delay
entirely if the daemon is up when chansrv starts the interface.
2024-05-23 16:35:53 +01:00
matt335672 e0a1339b34 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.
2024-05-21 12:33:17 +01:00
sefler 4599ac7bf6 apply patch generated by matt 2024-05-05 10:44:19 +08:00
seflerZ c42a09709e fix a bug in returning the init result. 2024-05-05 10:44:19 +08:00
matt335672 1e78b42022 Fix CI errors using C++ compiler 2024-05-05 10:44:19 +08:00
matt335672 a2064e51c1 Some changes to Unicode input processing
- xrdp is not now built with XRDP_IBUS to allow other input
  methods to be more easily supported.
- chansrv is only aked to start an input method if the client
  supports it.
- chansrv sends a status report back to xrdp when asked to start
  and input method.
- ./configure without --enable-ibus now works.
2024-05-05 10:44:19 +08:00
seflerZ b623766503 remote uncessary conditional compilation 2024-05-05 10:44:19 +08:00
seflerZ 8c98ed4a58 add conditional compilation annotations 2024-05-05 10:44:19 +08:00
seflerZ bcd690f037 code refactored 2024-05-05 10:44:19 +08:00
seflerZ 3b1cc551e4 format code 2024-05-05 10:44:19 +08:00
seflerZ d4e2e0a093 It works now 2024-05-05 10:44:19 +08:00
seflerZ bea72150fb change parameter types 2024-05-05 10:44:19 +08:00