Commit graph

767 commits

Author SHA1 Message Date
Demi Marie Obenour
3b444a4e6f Merge branch 'some-bounds-checks' into 'master'
Add some bounds checking to _reply functions

See merge request xorg/lib/libxcb!29
2026-04-17 23:58:56 -04:00
Alan Coopersmith
4d6e1c8fff xcb_util.c: Fix -Wextra-tokens warning with '#endif __WIN32' code
Closes: #90
Fixes: 17682ba ("xcb_util.c: don't build Unix domain socket pathcode on Windows")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/87>
2026-03-28 10:22:07 -07:00
Alan Coopersmith
17682ba754 xcb_util.c: don't build Unix domain socket path code on Windows
Fixes build failure and compiler warnings:

xcb_util.c: In function '_xcb_parse_display_path_to_socket':
xcb_util.c:109:46: error: invalid use of undefined type 'struct sockaddr_un'
  109 |     char path[sizeof(((struct sockaddr_un*)0)->sun_path) + 1 + 10];
      |                                              ^~
xcb_util.c: In function '_xcb_open':
xcb_util.c:256:11: warning: unused variable 'file' [-Wunused-variable]
  256 |     char *file = NULL;
      |           ^~~~
xcb_util.c:255:12: warning: unused variable 'filelen' [-Wunused-variable]
  255 |     size_t filelen;
      |            ^~~~~~~
xcb_util.c:254:17: warning: unused variable 'base' [-Wunused-variable]
  254 |     const char *base = unix_base;
      |                 ^~~~
xcb_util.c:248:9: warning: unused variable 'fd' [-Wunused-variable]
  248 |     int fd;
      |         ^~

Fixes: 6a7661f ("Get rid of PATH_MAX")
Closes: #87
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/86>
2026-03-15 14:07:09 -07:00
Alan Coopersmith
dc3178bc88 Strip trailing whitespace from source files
Performed with: `git ls-files | xargs perl -i -p -e 's{[ \t]+$}{}'`

`git diff -w` & `git diff -b` show no diffs from this change

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/85>
2026-03-15 17:24:25 +00:00
Vincent Torri
893a3cad2f xcb_util.c: fix compilation error on Windows with setsockopt
setsockopt() has different signatures on Unix and Windows. See
https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt

On Windows, the fourth arg is a `const char *`, not a a `const void *`.

Closes: #86
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/84>
2026-03-15 09:41:44 -07:00
incertia
93ee2ac73c c_client.py: fix getter because &array does not decay to base pointer
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/77>
2025-11-05 19:49:57 -05:00
incertia
a0d4be4593 c_client.py: document complex reply field accessor
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/74>
2025-11-03 09:07:07 +00:00
incertia
a6deeded59 c_client.py: move prev_field logic into is_reply branch
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/74>
2025-11-03 09:07:07 +00:00
incertia
d8130b5a56 c_client.py: use last field to get past the end of struct reply members
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/74>
2025-11-03 09:07:06 +00:00
Alan Coopersmith
bfa06609c3 xcbint.h: use offsetof() from stddef.h instead of defining our own
C89 and later guarantee it will be defined in <stddef.h> and then
we don't have to worry about using undefined behavior to define it.

Closes: #83
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/76>
2025-11-02 16:14:16 -08:00
Robert Knutsson
d2153baa99 CI: drop the ci-fairy MR check, which is both broken & no longer needed
Signed-off-by: Robert Knutsson <zybreak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/71>
2025-10-25 09:45:15 -07:00
Robert Knutsson
46446a980b configure.ac: Require python 3.6 or later 2025-10-21 16:00:29 +00:00
Robert Knutsson
4baf480f3d c_client.py: referenced param field was removed in bdc3f21a, update reference
Signed-off-by: Robert Knutsson <zybreak@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/69>
2025-10-19 21:14:51 +02:00
Robert Knutsson
34319d6ef2
c_client.py: _c_request_helper called with incorrect keyword argument
Signed-off-by: Robert Knutsson <zybreak@gmail.com>
2025-10-14 20:05:24 +02:00
Demi Marie Obenour
e81b999a72 Get rid of abstract sockets support
Abstract sockets support is an unfixable security risk.  Get rid of it.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/66>
2025-08-30 12:19:44 -07:00
Alan Coopersmith
5374250ca3 gitlab CI: update ci-templates and build images
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/67>
2025-08-30 12:02:41 -07:00
Samuel Thibault
6a7661f60a Get rid of PATH_MAX
There could be no upper limit on the length of a path according
to POSIX, therefore these macros may not be defined at all on
some systems (such as GNU Hurd). There is however a limit on
sizeof(struct sockaddr_un.sun_path), so use it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/65>
2025-07-08 23:05:34 +02:00
Alan Coopersmith
daf2c53976 add pure & const function attributes suggested by gcc -Wsuggest-attribute
This only covers the ones in the pre-written code.  There are many more
suggested in the generated code, which will require changing the generator
and will thus be handled separately.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Alan Coopersmith
021e887de9 xcb.h: use __has_attribute to check for attribute((__packed__)) support
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Alan Coopersmith
124690ba63 xcb.h: remove __solaris__ ifdef
Nothing was defining __solaris__ on Solaris in current build setup, and
it's not needed on Solaris 10 (released 2005) and later, which has
stdint.h.  (Solaris 2.6 - 9 had inttypes.h, but no stdint.h.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Demi Marie Obenour
68c41304ac Clean up bounds checks
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
48dbb5b6ca Avoid undefined behavior due to strict aliasing
This does not make XCB conform to the C99+ strict aliasing rules, but it
does use attributes to prevent GCC and Clang from assuming the rules are
followed in the cases where XCB does violate them.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
8adb5068af It compiles again 2024-08-29 17:53:44 -04:00
Demi Marie Obenour
6d965bf6c1 tmp 2024-08-29 17:53:44 -04:00
Demi Marie Obenour
cb9e1f4244 Null checks for malloc() return
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
4a8fac2831 Overflow checks for sumof()
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
9f0edb0b54 Add even more bounds checks
This adds checked _sizeof(), _unpack(), and _unserialize() functions.
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
0035d2673d Avoid blindly trusting the X server during setup
Validate the setup data returned by the server.  Details of the
validation are in comments.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
353919948a Ensure that *reply is set to NULL on error
This ensures it is not left uninitialized.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
f96f84ee45 Add some bounds checking to _reply functions
This is a step towards fixing a security vulnerability.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
06be1d845f Use and require C11 alignof
The current implementation of ALIGNOF invokes undefined behavior, and
C11 is over 12 years old already.  Just use C11 alignof().

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:44 -04:00
Demi Marie Obenour
1c900f7635 Add bounds-checking variants of reply functions and fix locking
Deprecate the unsafe functions.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2024-08-29 17:53:28 -04:00
Xi Ruoyao
ebea71700f c_client.py: Always open output files in UTF-8
The UTF-8 quotes can appear in man pages etc as well, not only C code.
For example, in xcb_composite_redirect_subwindows.3:

    xcb_composite_redirect_subwindows - Redirect all current and future
    children of ‘window’

Note that window is quoted by a pair of UTF-8 single quotes.

Closes: #72
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/60>
2024-06-06 03:11:02 +08:00
Matt Turner
622152ee42 libxcb 1.17.0 2024-04-15 14:53:31 +00:00
Matt Turner
4574ab269b configure.ac: Require xcb-proto >= 1.17.0
Signed-off-by: Matt Turner <mattst88@gmail.com>
2024-04-15 14:53:31 +00:00
Uli Schlachter
b78d304531 Always write C code in UTF-8
Some people apparently use non-utf8 locales and this caused errors when
xcb-proto started using some "fancy" quote marks. Fix this by always
using utf8 encoding.

Fixes: https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/72
Signed-off-by: Uli Schlachter <psychon@znc.in>
2024-04-15 14:40:41 +00:00
Erik Kurzinger
389f22d1cb Add xcb-dri3 dependency to xcb-present.pc.in
Present version 1.4 introduces a dependency on DRI3 for the DRI3Syncobj
protocol type.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2024-03-20 07:06:12 -07:00
Alan Coopersmith
86a478032b xcb_popcount: Use __builtin_popcount if compiler supports it
If the compiler knows of a better implementation for counting the number
of bits set in a word for the target CPU, let it use that, instead of the
classic algorithm optimized for PDP-6.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-08 22:11:43 +00:00
Alan Coopersmith
c268499c30 tests: fix -Werror=discarded-qualifiers errors in check_public.c
check_public.c: In function ‘parse_display_pass’:
check_public.c:32:32: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   32 |                         putenv("DISPLAY=");
      |                                ^~~~~~~~~~
In file included from check_public.c:4:
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c:57:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   57 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c: In function ‘parse_display_fail’:
check_public.c:73:32: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   73 |                         putenv("DISPLAY=");
      |                                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c:99:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   99 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c: In function ‘public_suite’:
check_public.c:244:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  244 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-02 11:47:47 -08:00
Alan Coopersmith
c671b9b30a
libxcb 1.16.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-02 11:13:37 -08:00
Fergus Dall
3c946010c8 Enable large file support
Signed-off-by: Fergus Dall <sidereal@google.com>
2023-11-07 17:42:42 +11:00
Peter Williams
02a7bbed39 Fix compilation on Windows
Merge request !30 broke compilation on Windows by introducing unbalanced
curly braces. This change restores the previous behavior on Windows:
only TCP is supported.
2023-08-28 18:01:39 +00:00
Alan Coopersmith
18c3f055e7 gitlab CI: use latest xcbproto from git to build against
Closes issue #70

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-08-20 11:36:40 -07:00
Thomas Klausner
453115f7ee configure.ac: drop pthread-stubs dependency on NetBSD 2023-08-20 17:38:39 +00:00
Alan Coopersmith
f11691a098 gitlab CI: regenerate container used for builds
This updates the included xcb-proto to the newly required 1.16.
As explained in issue #70, this is a quick workaround, not the
long-term fix for this problem.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-08-20 10:30:11 -07:00
Matt Turner
cc4b93c9cd libxcb 1.16
Signed-off-by: Matt Turner <mattst88@gmail.com>
2023-08-16 16:18:09 -04:00
Matt Turner
1519334652 configure.ac: Require xcb-proto >= 1.16.0
Signed-off-by: Matt Turner <mattst88@gmail.com>
2023-08-16 16:18:09 -04:00
Ilya Pominov
038636786a c_client: Fix crash in xcb_randr_set_monitor
Take into account c_need_sizeof when evaluating
xcb_protocol_request_t.count

Incorrect xcb_protocol_request_t.count causes a segmentation fault when
calling functions:
- xcb_randr_set_monitor{_checked}
- xcb_input_change_feedback_control{_checked}
- xcb_input_change_device_control{_unchecked}

Steps to reproduce:
Call xcb_randr_set_monitor() with valid arguments

OBSERVED RESULT
Segmentation fault
```
Process terminating with default action of signal 11 (SIGSEGV)
  Access not within mapped region at address 0x780
    at 0x4852925: memmove (in /usr/libexec/valgrind/vgpreload_memcheck-
amd64-linux.so)
    by 0x486967C: memcpy (string_fortified.h:29)
    by 0x486967C: send_request (xcb_out.c:59)
    by 0x486967C: send_request (xcb_out.c:46)
    by 0x486967C: xcb_send_request_with_fds64 (xcb_out.c:338)
    by 0x48699FC: xcb_send_request (xcb_out.c:359)
    by 0x4891F11: xcb_randr_set_monitor_checked (randr.c:5350)
```

EXPECTED RESULT
Function returns cookie

Amend: 77b594f958

Signed-off-by: Ilya Pominov <ipominov@astralinux.ru>
2023-04-10 20:06:52 +03:00
Demi Marie Obenour
8935793f1f Add tests for unix socket parsing
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-25 15:27:50 -04:00
Demi Marie Obenour
095255531b DISPLAY starting with / or unix: is always a socket path
If DISPLAY starts with / or unix:, do not check for anything but a full
filesystem socket path.  In particular, abstract AF_UNIX sockets and TCP
sockets will not be used in this case.   Also be stricter about parsing
the screen part of /path.screen displays, and bail out after all stat()
errors other than ENOENT.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-25 13:15:08 -04:00