Commit Graph

26 Commits

Author SHA1 Message Date
matt335672 c4727ad8f3 Replace X11 display number with a display string
As far as possible, use of the X11 display number is kept to
X11-specific routines. This is to make it easier to restructure
the code to add non-X11 display support.
2026-03-04 14:34:31 +00:00
firewave 214cf50df5 fixed some unreadVariable Cppcheck warnings 2026-03-03 16:33:51 +01:00
matt335672 bc0e169451 Rationalise g_htoi() / xrdp_wm_htoi()
xrdp contains two functions which do similar things:-
- g_htoi() converts a hex string to an integer, ignoring unrecognised
  characters
- xrdp_wm_htoi() converts a hex string to an integer, ignoring leading
  whitespace, but terminating on unrecognised characters

An analysis of the uses of g_htoi() shows that the only place where
unrecognised characters might be encountered is parsing lines from
xrdp_keyboard.ini, where all values have an '0x' prefix (i.e. the 'x'
is unrecognised)

An analysis of xrdp_wm_htoi() shows that the functionality to ignore
leading whitespace is not used.

Both functions are replaced with a re-written g_htoi() which is const-
correct and provided with test cases. This function behaves in
the same way as the atoi() library function, in that it terminates on
an unexpected character.

The use of g_htoi() in parsing lines from xrdp_keyboard.ini is replaced
with a call to g_atoix() which handles the '0x' prefix correctly.
2025-03-31 15:36:51 +01:00
matt335672 960ea7ce05 Add support for strlcpy()
Too many places in xrdp use strncpy() to copy strings to fixed-length
buffers, when this is not the correct function to use.

This PR makes sure strlcpy() from the BSDs is available as a saner
alternative. This function is available by default on Linux and FreeBSD.
2025-03-25 11:08:16 +00:00
matt335672 0f46b7961c Fix Coverity error triggered in utf8_get_next_char() 2025-01-24 11:21:32 +00:00
matt335672 2a4b40a20c Address some Coverity warnings 2025-01-13 15:24:33 +00:00
matt335672 62a51dead9 Fix g_strtrim() regression
Commit 36ea4a3 failed to take UTF-8 characters into account on
platforms with signed char.
2024-01-02 11:07:28 +00:00
matt335672 f5f67e2e80 Remove g_mbstowcs() and g_wcstombs()
These calls are now replaced with explicit UTF conversion routines in
the common/string_calls.[hc] and common/parse.[hc] modules.

Also removed:-
- The support code in common/os_calls.c to set the locale to use
  these routines.
- The twchar type in arch.h
2023-10-23 14:19:49 +01:00
matt335672 36ea4a3f86 Remove mbstowcs/wcstombs from g_strtrim()
Because of the way UTF-8 encoding works, there is no need to
use mbstowcs/wcstombs in the implementation of this function.
2023-10-23 14:15:46 +01:00
matt335672 0463e552dc Add UTF-8 / UTF-32 conversion routines
These are intended to replace non-UTF-16 uses of mbstowcs() / wcstombs()
2023-10-18 10:07:49 +01:00
matt335672 ce42e3e12d Replace g_strsignal() with g_sig2text()
This call provides a textual representation of a signal number, i.e.
SIGHUP is mapped to "SIGHUP"

Unit tests are also added.
2023-06-12 16:19:17 +01:00
matt335672 0f32661056 Add g_strsignal() to string_calls module 2023-06-08 16:32:24 +01:00
Nexarian 89e178e7c9 Add function to split string into list.
- With working unit tests.
2023-03-03 18:33:33 -05:00
matt335672 61bfb264de Add bitmask to character string conversions 2022-05-18 12:35:07 +01:00
matt335672 c1d2dcfc7f Cosmetic fixes to string_calls 2022-05-18 12:35:07 +01:00
Kentaro Hayashi 69ea406440 Add g_str_to_bitmask utility function
It should be used for comma separated configuration to bitmask.

e.g. RestrictOutboundClipboard = text, file, image
2022-01-14 10:17:02 +09:00
matt335672 a7b48cd1cf Added more string calls + fix prototypes
- Added g_strrchr() and g_strstr()
- Made C prototypes for g_strchr() and g_strnchr() compatible with
  expected C library functions
2021-10-25 16:13:09 +01:00
matt335672 62ca216d4d Improve security level logging at ISO layer 2021-09-03 12:30:02 +01:00
TOMATO-ONE e3ffad77ca neutrinordp: Allow fixed keyboard lauout information to be sent to remote. #1933 2021-07-20 01:08:45 +09:00
matt335672 85b101dfb2 Added string function g_strnchr() 2021-06-08 14:11:17 +01:00
Alexandre Quesnel 52707ac686 Fixing formatting with astyle 2021-05-08 16:58:11 +00:00
Alexandre Quesnel 09174ccd4d Adding g_strnjoin() with units tests 2021-04-14 04:41:53 +00:00
matt335672 86c87b6f15 Move get_display_num_from_display to string_calls module 2021-04-13 12:16:00 +01:00
Alexandre Quesnel b8d02823d1 Extracting bytes_to_hexdump function from logging implementation 2021-03-26 13:58:27 +00:00
matt335672 0a1a8f40e5 Moved a lot of string funcs to string_calls module 2020-12-22 11:57:24 +00:00
matt335672 5523847540 Allow FuseMountName for chansrv to be absolute path 2020-12-21 12:36:31 +00:00