Commit Graph

2913 Commits

Author SHA1 Message Date
Mikhail Dmitrichenko
9036215b02 dix: avoid null ptr deref at doListFontsAndAliases
In the `doListFontsAndAliases` function in dixfonts.c, when a font alias
is encountered (`err == FontNameAlias`) as a result of
`list_next_font_or_alias` call, the code allocates memory for
`resolved` variable (`resolvedlen + 1` bytes) for storing target font
name. In this case, if the `malloc(resolvedlen + 1)` call fails,
`resolved` remains NULL.

Later, when check (`else if (err == FontNameAlias)`) is TRUE, the code
uses `memcpy` to copy nullable `resolved` into `tmp_pattern` without
checking if `resolved` is NULL, so there is a potential null ptr
dereference.

This commit replaces `malloc` with `XNFalloc` for allocating memory for
`resolved`. `XNFalloc` will internally check result of `malloc` and stop
program execution if allocation was failed, preventing potential NULL
dereferencing.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2114>
2026-03-16 13:26:38 +01:00
Diego Viola
639551d032 treewide: fix typos
Signed-off-by: default avatarDiego Viola <diego.viola@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2138>

---------------------------------------------------------------------------

One of the spelling errors was moved to another file and fixed there

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2026-03-16 13:11:07 +01:00
stefan11111
e6a0fa4b0c Treewide: Fix typos
Signed-off-by: Diego Viola <diego.viola@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2134>

----------------------------------------------------------------------------

This commit is the result of `git apply commit.diff --reject`
applied on e8f4522312

67c82078fe does not
apply to Xlibre

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2026-03-16 13:11:07 +01:00
Enrico Weigelt, metux IT consult
62b0add858 mi: move ValidateRec to mi_priv.h and rename to MiValidateRec
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-02-10 18:27:41 +01:00
Enrico Weigelt, metux IT consult
d28d18ff00 dix: replace "screen" by "pScreen" in AttachDevice()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-02-09 19:28:45 +01:00
Enrico Weigelt, metux IT consult
4642d6207f os: unexport SeatId and move it to dix settings
Not used by any external module/driver, so no need to keep it
public. Also move it to the new dix settings code and rename it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-02-03 11:34:14 +01:00
Enrico Weigelt, metux IT consult
4ee2a5e16a dix: inline SProcGrabButton()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-01-31 16:20:28 +01:00
Enrico Weigelt, metux IT consult
28d930b16c dix: inline SProcQueryColor()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-01-31 16:16:19 +01:00
Enrico Weigelt, metux IT consult
a9c2edfffd dix: encapsulate ScreenRec::UnrealizeWindow() call in helper function
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-01-08 17:44:11 +01:00
Enrico Weigelt, metux IT consult
3adf207be1 dix: tiny cleanup in CrushTree()
Make it a little bit easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-01-07 19:18:54 +01:00
Enrico Weigelt, metux IT consult
d45aeab1b6 dix: inline ProcQueryExtension()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 12:01:03 +01:00
Enrico Weigelt, metux IT consult
b19f3babe7 dix: inline SProcCreateGlyphCursor()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 12:00:50 +01:00
Enrico Weigelt, metux IT consult
5c3980b407 dix: inline ProcSetScreenSaver()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 11:59:08 +01:00
Enrico Weigelt, metux IT consult
07b0c67c28 dix: inline SProcRotateProperties()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 11:58:53 +01:00
Enrico Weigelt, metux IT consult
7a2a3c9016 dix: inline SProcGrabPointer()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 11:58:41 +01:00
Enrico Weigelt, metux IT consult
a47b2ce91c dix: inline SProcGetProperty()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 11:58:24 +01:00
Enrico Weigelt, metux IT consult
ca35b825a3 dix: inline SProcLookupColor()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-19 11:58:11 +01:00
Enrico Weigelt, metux IT consult
2285961661 dix: fix inttype mismatches in AllocARGBCursor & AllocGlyphCursor
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 16:28:25 +01:00
Enrico Weigelt, metux IT consult
aefde94a2d meson: drop obsolete vendor information options
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-17 13:52:37 +01:00
Aggelos Tselios
729f471b9e dix: move alwaysCheckForInput declaration to first use
Move the declaration of alwaysCheckForInput closer to where it is first
used and initialize it at declaration rather than assigning it later.

Signed-off-by: Aggelos Tselios <aggelostselios777@gmail.com>
2025-12-15 14:10:59 +01:00
Enrico Weigelt, metux IT consult
4609d2e5e8 dix: Dispatch() separate variable for read result
Mixing result variables for separate things is making the code hard
to understand, so add a new local variable for temporarily storing
the result of ReadRequestFromClient().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:49:15 +01:00
Alan Coopersmith
2be080c4e3 dix: set errorValue correctly when XID lookup fails in ChangeGCXIDs()
dixLookupResourceByType always overwrites the pointer passed in as the
first arg, so we shouldn't use the union it's in after that to get the
requested XID value to put in the errorValue.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1857
Fixes: 2d7eb4a19b ("Pre-validate ChangeGC XIDs.")
Reported-by: Mouse <mouse@Rodents-Montreal.ORG>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2111>
2025-12-09 17:41:25 +01:00
Enrico Weigelt, metux IT consult
609ea42a62 include: don't install client.h anymore
not included by any drivers, so doesn't need to be in SDK anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-05 19:44:59 +01:00
Enrico Weigelt, metux IT consult
19ee44b607 treewide: drop including <dix-config.h> from private includes
All .c sources must include <dix-config.h> at the very first.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 19:50:44 +01:00
Enrico Weigelt, metux IT consult
36503b11b7 dix: consistenly name reply structs "reply" instead of "rep"
Preparation for future use of generic reply assembly macros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 16:28:06 +01:00
Enrico Weigelt, metux IT consult
01502a4ddd dix: request_priv.h: fix X_REQUEST_REST_COUNT_CARD16()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 14:26:41 +01:00
Enrico Weigelt, metux IT consult
a173278c4f dix: make SwapLongs() inline
a) trade a little bit of code size for speed
   (depending on exact caller, compiler might also optimize a lot)
b) reduce the need for exported, but non-public symbol

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-03 14:30:02 +01:00
Enrico Weigelt, metux IT consult
6a320e76cb dix: add macros for request handlers and swapping
add some macros for making request handlers and byte swapping easier:

    * X_REQUEST_HEAD_STRUCT(type) and X_REQUEST_HEAD_AT_LEAST(type)
      declare header struct pointers and check size
    * X_REQUEST_FIELD_CARD16(field)
      swaps a CARD16 (word) header field (if neccessary)
    * X_REQUEST_FIELD_CARD32(field)
      swaps a CARD32 (dword) header field (if neccessary)
    * X_REQUEST_REST_CARD16()
      swaps remaining CARD16 array payload (if necessary)
    * X_REQUEST_REST_CARD32()
      swaps remaining CARD32 array payload (if necessary)
    * X_REQUEST_REST_COUNT_CARD16(count)
      check swaps `count` CARD16 payload fields and checks size
    * X_REQUEST_REST_COUNT_CARD32(count)
      check swaps `count` CARD32 payload fields and checks size

How to use them:

    1. put X_REQUEST_HEAD_STRUCT() or X_REQUEST_HEAD_AT_LEAST() ontop of each Proc*()
    2. add X_REQUEST_FIELD_*() et al below, for all fields to be swapped and
       drop the corresponding SProc*()'s
    3. let the dispatchers call Proc*() instead of SProc*()

Notes:

    * the length field is already swapped before request handlers called

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-03 10:58:14 +01:00
Oleh Nykyforchyn
f4115e69eb dix: initialize all screens before proceeding to gc's, root windows etc
Current code walks along all screens and initializes screen resources,
then gc's, stipples, root windows for each of them, hence after
the first screen registering new private keys is no more possible.
This crashes modesetting driver if it is not initialized before others.

This patch makes screen resources for all screen initialize first, hence
all necessary private keys (including of the type PRIVATE_WINDOW) are
initialized before root windows are created.

Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
2025-12-03 09:24:33 +01:00
Marc-Alexandre Espiaut
e1b3bbafa8 dix: remove dixLookupBuiltinColor() unused screen argument
Signed-off-by: Marc-Alexandre Espiaut <76531574+malespiaut@users.noreply.github.com>
2025-11-28 18:43:40 +01:00
Enrico Weigelt, metux IT consult
e14d352661 dix: move GCAllBits define into private header
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 20:05:59 +01:00
Enrico Weigelt, metux IT consult
33729b1361 include: windowstr.h: unexport w*() macros
These aren't used by any drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:54:42 +01:00
Enrico Weigelt, metux IT consult
ff8d26df21 include: windowstr.h: unexport SameBackground() and SamBorder() macros
Not used by any drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:49:14 +01:00
Enrico Weigelt, metux IT consult
9b8d7d1eb9 treewide: don't include <region.h> anymore
Nothing in there that we need, include <regionstr.h> instead.
But keeping the file in place, until all external consumer have
been migrated.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:27:27 +01:00
Oleh Nykyforchyn
0230c6e074 dix: reexport ConnectionInfo for NVidia 390
This patch exports ConnectionInfo in server_priv.h and references
it in globals.c to force exporting.

Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
2025-11-27 17:06:36 +01:00
Enrico Weigelt, metux IT consult
85fae9bffb dix: inline SProcAllocColor()
Now that we have untwisted Xinerama side, it's trivial to inline
the few lines for byte-swapping into the actual handlers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 13:46:37 +01:00
Alan Coopersmith
e352fdecfe dix: handle allocation failure in DeviceFocusEvent()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../dix/enterleave.c:786:5:
 warning[-Wanalyzer-possible-null-dereference]:
 dereference of possibly-NULL ‘xi2event’

Fixes: 3f37923a72 ("Xi: send XI2 focus events." in Xorg 1.10.0)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2078>
2025-11-27 13:36:49 +01:00
Enrico Weigelt, metux IT consult
92a015504e dix: make BITMAP_SCANLINE_UNIT private
Not used by any external drivers, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 12:05:55 +01:00
Enrico Weigelt, metux IT consult
5532917d76 os: move AllowByteSwappedClients setting into DIX
Adding new source and header that's going to host all DIX
settings (set via cmdline or xf86 config file) in the future.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 10:44:23 +01:00
Enrico Weigelt, metux IT consult
8039c2cbf1 dix: unexport SwapLongs()
Not used by any external drivers, so no need to keep it in public SDK.
Since it's used by internal modules, still needs to be _X_EXPORT'ed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-25 18:26:02 +01:00
Mike Gelfand
f40bfb5ca9 dix: move include guards up to wrap the whole file
See: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
Signed-off-by: Mike Gelfand <mikedld@mikedld.com>
2025-11-21 15:20:11 +01:00
Enrico Weigelt, metux IT consult
d66dea68af dix: dixfonts: drop unused GetFontPath()
Not used anywhere, neither in Xserver nor in drivers, so no need
to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:26:32 +01:00
Enrico Weigelt, metux IT consult
95499a9525 dix: unexport enableIndirectGLX
Still needs to be _X_EXPORT'ed for internal modules, but
not supposed to be visible to external drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:25:41 +01:00
Enrico Weigelt, metux IT consult
6a1bdcedd3 dix: unexport DeleteProperty()
Not used by any external driver, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:35 +01:00
Enrico Weigelt, metux IT consult
40acb2d83e dix: unexport PrintPassiveGrabs() and PrintWindowTree()
These are only for internal debug output, not needed for drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:18 +01:00
Enrico Weigelt, metux IT consult
8059c260c2 dix: unexport XIUnregisterPropertyHandler() and XIDeleteAllDeviceProperties()
Not used by any external drivers, so no need to keep the exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:21:37 +01:00
Enrico Weigelt, metux IT consult
416f69eb88 include: misc.h: unexport lowbit() macro
Not used by any drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:20:07 +01:00
Enrico Weigelt, metux IT consult
44077ee11c dix: unexport screenIsSaved and HasSaverWindow()
These aren't used by any external drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:52:23 +01:00
Enrico Weigelt, metux IT consult
b0ac921156 dix: unexport GrabInProgress
Only internally within OS layer and screen saver logic,
so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:42:29 +01:00
Enrico Weigelt, metux IT consult
064e5f2ddf os: drop OsCleanup()
Since we're always terminating now, everbody can call UnlockServer()
directly, so we don't need that extra function anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 11:19:02 +01:00