Pierre Ossman
94d6a693ea
Don't allow surrugate code points in UTF-8
These are not valid outside of UTF-16 so seeing them in a UTF-8 sequence
means that something is wrong with that sequence. Best to filter them
out rather than letting them propagate and have unknown effects.
1 year ago
Pierre Ossman
c061a78dc1
Clean up string encoding handling
We should handle this in the low-level protocol code as much as possible
to avoid mistakes. This way the rest of the code can assume that strings
are always UTF-8 with \n line endings.
1 year ago
Pierre Ossman
19df176862
Consistently use uint8_t for data buffers
These will always be byte streams at heart, so let's try to keep them
with a proper type. Should make it clearer how they will be used.
1 year ago
Pierre Ossman
15a0da6157
Merge branch 'types' of https://github.com/CendioOssman/tigervnc
1 year ago
Pierre Ossman
cbed625888
Merge branch 'vncsession-create-homedir' of https://github.com/zpytela/tigervnc
1 year ago
Pierre Ossman
4a482d541c
Merge branch 'master-clipboard-check-state-before-access' of https://github.com/MarkMielke/tigervnc
1 year ago
Pierre Ossman
6b7a69e807
Throw exception instead on bad access check
An assert will kill the entire server, which is overly harsh when there
is a problem with a single connection. Instead, throw an exception which
will just disconnect that specific client.
1 year ago
Мирослав Николић
75e6e8e35c
Update Serbian translation
1 year ago
Zdenek Pytela
717d787de8
SELinux: Allow vncsession create ~/.vnc directory
Addresses the following AVC denial:
type=PROCTITLE msg=audit(01/12/2023 02:58:12.648:696) : proctitle=/usr/sbin/vncsession fedora :1
type=PATH msg=audit(01/12/2023 02:58:12.648:696) : item=1 name=/home/fedora/.vnc nametype=CREATE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=PATH msg=audit(01/12/2023 02:58:12.648:696) : item=0 name=/home/fedora/ inode=262145 dev=fc:02 mode=dir,700 ouid=fedora ogid=fedora rdev=00:00 obj=unconfined_u:object_r:user_home_dir_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(01/12/2023 02:58:12.648:696) : cwd=/home/fedora
type=SYSCALL msg=audit(01/12/2023 02:58:12.648:696) : arch=x86_64 syscall=mkdir success=no exit=EACCES(Permission denied) a0=0x7fff47d52540 a1=0755 a2=0x0 a3=0x0 items=2 ppid=2869 pid=2880 auid=fedora uid=fedora gid=fedora euid=fedora suid=fedora fsuid=fedora egid=fedora sgid=fedora fsgid=fedora tty=(none) ses=8 comm=vncsession exe=/usr/sbin/vncsession subj=system_u:system_r:vnc_session_t:s0 key=(null)
type=AVC msg=audit(01/12/2023 02:58:12.648:696) : avc: denied { create } for pid=2880 comm=vncsession name=.vnc scontext=system_u:system_r:vnc_session_t:s0 tcontext=system_u:object_r:vnc_home_t:s0 tclass=dir permissive=0
Resolves: rhbz#2143704
1 year ago
Mark Mielke
995f443ef7
VNCSConnectionST clipboard functions should check state before access.
Clipboard functions may run on connections that are not yet at
RFBSTATE_NORMAL. Due to recent hardening of the accessCheck() function,
it is important to validate that the state is RFBSTATE_NORMAL before
calling accessCheck().
Fixes #1599 .
1 year ago
Pierre Ossman
4c9b0ba913
Merge "Pixel" type in to PixelFormat header
It's a type specific to that class, so let's keep them close for
clarity.
1 year ago
Pierre Ossman
1e3484f201
Sanity check when cleaning up keymap changes
Make sure we don't send a bogus request to the X server in the (common)
case that we don't actually have anything to restore.
1 year ago
Pierre Ossman
f55abd7b00
Use operator overloading for comparison
It is much more natural than custom methods for this very common
operation.
1 year ago
Pierre Ossman
9854463f16
Warn if Point/Rect/Region methods are used wrong
It is easy to get confused if these methods modify the existing object,
or return a new one. So let's mark the return value as critical so the
compiler can help out if someone gets it wrong.
1 year ago
Pierre Ossman
192a7bec96
Avoid redefining errno
This can have unexpected consequences as some code may rely on it being
a simple variable. Instead to what we do in Socket, which is to define a
unique name for getting socket error numbers.
1 year ago
Pierre Ossman
03a2057e9e
Remove unneeded header from SDesktop.h
It doesn't use any exceptions, so stop including the header for it.
1 year ago
Pierre Ossman
5db843ead6
Remove unused rfb/util.h includes
These files don't use anything from this header, so remove the include.
This exposes some missing includes in other places, though. So add an
explicit include in the files that were relying on an indirect
inclusion.
1 year ago
Pierre Ossman
fd243a8d3a
Remove "str" prefix from string helpers
This matches the naming in STL, which is what we are mostly mimicing now
that we are using std::string for these functions.
1 year ago
Pierre Ossman
3143bfa154
Use standard C string functions
It's just confusing that we have our own variety that isn't compatible.
1 year ago
Pierre Ossman
4293dc42f6
Remove custom CharArray type
It has now been replaced, mostly by std::string, so remove the actual
type definition.
1 year ago
Pierre Ossman
adaedc9629
Use std::string for string memory management
Avoids a bit of complexity by delegating that handling to a string
object.
1 year ago
Pierre Ossman
b99daadb05
Use std::string instead of CharArray
Let's use a more common type instead of something homegrown. Should be
more familiar to new developers.
1 year ago
Pierre Ossman
e6c5b29f12
Use std::vector for temporary char arrays
It's more standard and familiar than our custom CharArray type, and it
still gives us automatic freeing of the buffer.
We could probably have used std::unique_ptr instead, but we are
currently targeting older compilers where C++11 isn't standard yet.
1 year ago
Pierre Ossman
15a3939126
Free char buffer directly
It's extreme overkill to inherit from CharArray just to get the
automatic freeing of the buffer when the object is destroyed.
1 year ago
Pierre Ossman
19badc4def
Make strSplit() simpler and safer
Get rid of all the magical re-allocation and shuffling and instead just
return a new set of strings that is fully splitted. Will consume a bit
more memory, but is a lot safer to use as there is less confusion about
ownership of memory.
1 year ago
Pierre Ossman
337dbc3922
Return std::string instead of dynamic allocations
We mostly use classical C strings, but the memory management around them
can get confusing and error prone. Let's use std::string for the cases
where we need to return a newly allocated string.
1 year ago
Pierre Ossman
dde95fccca
Specify expected array size in arguments
The compiler doesn't enforce this, but it at least documents the
expected array size.
1 year ago
Pierre Ossman
d608a30d57
Use fixed size character buffer
We know the needed space here, so let's keep it simple with a constant
size string buffer.
1 year ago
Pierre Ossman
ef8c84eb75
Remove trailing slash from getvnchomedir()
It should return a path to the directory itself, just like its sister
function getuserhomedir().
1 year ago
Pierre Ossman
803a6ae087
Namespace directory functions
All library functions should be in a proper namespace.
1 year ago
Pierre Ossman
334398153b
Better fallback for missing peer address
A blank string might be very confusing, depending on where this will be
used. Let's give something more visible back in the cases where we
cannot get the proper name for the peer.
1 year ago
Pierre Ossman
5c1ac16776
Return static char buffer from some methods
This mimics how some system functions (like inet_ntop()) work, and
avoids complexity around ownership of the returned string buffer.
The downside is that the string must be consumed directly as it will be
overwritten on the next call, but that is not an issue with the current
usage.
1 year ago
Pierre Ossman
1af2a56f75
Replace tabs with spaces
Use the same indentation we use in all other files.
1 year ago
Pierre Ossman
818694ba6a
Use string literal instead of dynamic buffer
These don't need to be changed, so let's just keep it simple with a
constant string literal.
1 year ago
Pierre Ossman
51347ef875
Remove unneded string duplication
It's unclear why this was initially added. The function takes string
constants, so it is not going to modify these.
1 year ago
Pierre Ossman
7f20bff356
Remove unneeded CharArray:s
Avoid complicating things by moving things in to a second buffer here as
there is no need for it.
1 year ago
Pierre Ossman
741300728a
Use StringParameters directly
We don't need to make extra copies of the string in most cases, so let's
simplify the code and access the string directly when we can.
1 year ago
Pierre Ossman
77f0a61ec8
Get rid of TCHAR magic
We never use Windows' "UNICODE" mode anyway, so let's get rid of this
complexity.
1 year ago
Pierre Ossman
2047dae22f
Return std::vector instead of dynamic allocation
This makes memory management more clear and robust when using these
helper functions.
1 year ago
Pierre Ossman
ea6afa9b79
Avoid duplicating configuration setting
Let the string helpers call the more fancy setParam(). This makes sure
we can avoid duplicating things.
1 year ago
Pierre Ossman
cee09051e6
Make sure length is reset on assignment
Otherwise the old length is preserved, which will result in NULL pointer
dereferencing if the parameter is ever accessed.
1 year ago
Pierre Ossman
cf931f8c9a
Clean up BinaryParameter typing
This is explicitly a byte sequence, so let's try to keep a consistent
typing.
1 year ago
Pierre Ossman
07e541678c
Move hex conversion helpers to util
These are used here and there so let's make them more general rather
than hiding them in the stream classes.
1 year ago
Fabio T
4895f53aef
Update Friulian translation
1 year ago
Pierre Ossman
d98720b736
Use std::vector for basic data arrays
Avoid our own custom types in favour of what's already included with
C++.
1 year ago
Pierre Ossman
6881c895ab
Use stdint types
Avoid having our own custom stuff and instead use the modern, standard
types, for familiarity.
1 year ago
Pierre Ossman
baca73d032
Use templates for optimized code
Avoid preprocessor magic and instead rely on templating to generate
optimized functions for performance critical code.
1 year ago
Pierre Ossman
cb4f920199
Remove old mingw CMake checks
This should have been removed with the code using these defines in
03ca975
.
1 year ago
Pierre Ossman
bf0fb9129d
Fix CRLF line endings
Everything else uses LF line endings, so fix up the few stray ones.
1 year ago
Pierre Ossman
a434ef3377
Merge branch 'libtool' of https://github.com/CendioOssman/tigervnc
1 year ago