Commit Graph

78 Commits

Author SHA1 Message Date
Simon Ser
3c12a7a1be cursor: fix whitespace in function args definitions
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
a46d8be4e1 cursor: remove struct typedefs, rename to snake case
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
21394fd5f7 cursor: fix spacing around conditions and loops
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
315126d3bd cursor: fix indentation
Use tabs.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
450bb7c145 cursor: remove unnecessary if before free
free(NULL) is valid and is a no-op.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
92e758834c cursor: fix variable declaration style
Use a single space between type and variable name.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
b0a4e63351 cursor: fix struct declaration style
Use tabs for indentation, don't use tabs to align field names.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
329be63d6b cursor: fix define style
Don't use tabs, don't align.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
5f5f1da691 cursor: drop whitespace before parens in function calls
This is in line with the rest of the Wayland code style.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
13d4ae01cb cursor: drop XCURSOR_LIB_* defines
These are unused.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
7658cff241 cursor: drop XcursorTrue and XcursorFalse
Just use <stdbool.h> instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
4ea5ad1d11 cursor: remove private Xcursor int typedefs
Just use the types directly instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
2dcc35af81 cursor: use MAP_FAILED instead of hardcoded constant
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-06 21:57:24 +02:00
Vlad Zahorodnii
4ebd997de2 cursor: Remove unused XcursorLibraryLoadImages() function
XcursorLibraryLoadImages() function is unused and not exported according to
objdump, so its removal should be an ABI compatible change.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2022-02-05 14:33:32 +00:00
Simon Ser
0d314c4a04 build: don't rely on implicit GNU extensions
Currently libwayland assumes GNU extensions will be available, but
doesn't define the C standard to use. Instead, let's unconditionally
enable POSIX extensions, and enable GNU extensions on a case-by-case
basis as needed.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-10 15:08:46 +01:00
Simon Ser
ba82e0d806 meson: override dependencies to ease use as subproject
Make it easier to use Wayland as a Meson subproject by overriding
dependencies we define. This allows to easily build Wayland as a
subproject like so:

    subproject('wayland', required: false, default_options: ['documentation=false'])

After this statement, the wayland-* dependencies will use the subproject
instead of the system if available.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-12-08 00:27:58 +01:00
Simon McVittie
0cdd2a5c54 build: Include the Wayland minor version in libraries' ABI versions
The ABI of a shared library on Linux is given by a major version, which
is part of the SONAME and is incremented (rarely) on incompatible
changes, and a minor version, which is part of the basename of the
regular file to which the SONAME provides a symlink.

Until now, the ABI minor version was hard-coded, which means we can't
tell which of a pair of Wayland libraries is newer (and therefore
likely to have more symbols and/or fewer bugs).

libwayland-egl already had ABI major version 1, so we can use the
"marketing" version number as the ABI major.minor version number
directly, so Wayland 1.19.90 would produce
libwayland-egl.so.1 -> libwayland-egl.so.1.19.90.

libwayland-cursor and libwayland-server have ABI major version 0,
and OS distributions don't like it when there's a SONAME bump for no
good reason, so use their existing ABI major version together with
the "marketing" minor version:
libwayland-cursor.so.0 -> libwayland-cursor.so.0.19.90.

If the Wayland major version number is incremented to 2, we'll have to
rethink this, so add some error() to break the build if/when that
happens. Assuming that Wayland 2.0 would involve breaking changes,
the best way would probably to bump all the SONAMEs to
libwayland-foo.so.2.

Resolves: https://gitlab.freedesktop.org/wayland/wayland/-/issues/175
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-28 12:46:06 +00:00
Simon Ser
6ebe3cfed0 cursor: remove unused wl_cursor_theme.name
Let's just delete this field since it's not used anywhere and not
exposed in our public API.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-08-06 09:26:03 +00:00
Simon Ser
2dfa0dcb24 cursor: rename load_default_theme to load_fallback_theme
The theme getting loaded by this function is not to be confused
with the theme named "default" located on the filesystem. Instead,
it's a minimal theme directly bundled into libwayland-cursor.

Make this clearer by naming this theme "fallback".

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-08-05 17:24:02 +02:00
Olivier Tilloy
f80879c03c cursor: Try to fall back to a default xcursor theme first
The use case is systems where for some reason the current xcursor theme
cannot be accessed (an application packaged as a strictly confined snap,
for example).

Before falling back to wayland's default cursor theme, it is worth
trying the xcursor theme called "default", which hopefully looks better
than the former.

Fixes: https://gitlab.gnome.org/Community/Ubuntu/gnome-sdk/-/issues/6

Signed-off-by: Olivier Tilloy <olivier.tilloy@canonical.com>
2021-08-05 17:09:40 +02:00
Tobias Stoeckmann
abcf1048e2 cursor: fix crash with weird input files
If a cursor file contains multiple images for the same size, this
typically indicates an animation. The compositor weston uses
wl_cursor_frame_and_duration to figure out at which time a specific image
should be shown.

The total delay is the sum of all image delays. But if all images have a
delay of 0, the total delay is 0 as well. The code does not check for this
special condition and triggers a floating point exception by eventually
performing a modulo operation with 0.

This, of course, could also happen if the sum of all image delays
triggers an unsigned int overflow. But since a comment in the code
already indicates that it does not try to "fix" handling of weird files,
I would argue that it's "okay" if that happens. At least the program
won't crash.

Proof of Concept:

install -D ~/.icons/poc/cursors
base64 -d > ~/.icons/poc/cursors/left_ptr << EOF
WGN1chAAAAAAAAEAAgAAAAIA/f8BAAAAKAAAAAIA/f8BAAAAKAAAACQAAAACAP3/AQAAAAEAAAAB
AAAAAQAAAAEAAAABAAAAAAAAAAAAAAA=
EOF
cat > /tmp/weston.ini << EOF
[shell]
cursor-theme=poc
EOF
weston -c /tmp/weston.ini

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2021-06-02 13:46:33 +00:00
Tobias Stoeckmann
ed55438366 cursor: fix CVE-2013-2003
The libXcursor fix for CVE-2013-2003 has never been imported into
wayland, leaving it vulnerable to it.

Changing the argument type to an unsigned type is an effective merge of
Ilja Van Sprundel's commit in libXcursor.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2021-05-02 21:35:23 +02:00
Alexander Dunaev
0aebb5b94d cursor: add one more directory to XCURSORPATH
The user may install cursor themes manually, and the desktop environment
may provide a special directory for storing them.  For instance, GTK puts
those themes into ~/.local/share/icons, and many Linux distributions suggest
using that directory for user-specific themes.  However, users of
libwayland-cursor cannot load these themes using the API provided by the
library because the latter does not look into that directory.

This patch adds ~/.local/share/icons to the search path, so user-specific
themes can be loaded through the API provided by libwayland-cursor.

Signed-off-by: Alexander Dunaev <adunaev@igalia.com>
Reviewed-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
2021-04-27 11:16:17 +00:00
Simon Ser
3bda3d1b47 build: drop autotools
Meson now replaces autotools.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-03-05 09:15:04 +00:00
Maxime Roussin-Bélanger
0f0951d5c4 cursor: fix typo "insufficent" 2020-12-17 16:03:14 -05:00
ganjing
1ea08d748c cursor/convert_font.c: malloc cannot guarantee that the memory allocated is always successful 2020-10-29 13:00:20 +00:00
Valentin
1ab6a81816 Fix undefined behavior
Without the casts the bytes accesses get converted to int. but int is
not guaranteed to be 4 bytes large. Even when it is 4 bytes large
`bytes[3] << 24` does not fit because int is signed.

Signed-off-by: Valentin Kettner <vakevk@gmail.com>
2020-09-04 12:27:33 +02:00
Valentin
fc3beac71f Use fixed size integer type
This type is meant to be 4 bytes large as seen in _XcursorReadUInt which
always reads 4 bytes. An unsigned int is often 4 bytes large but this
isnt' guaranteed so it is cleaner to use the exact type we want.

Signed-off-by: Valentin Kettner <vakevk@gmail.com>
2020-09-04 12:27:23 +02:00
Emmanuel Gil Peyrot
c81cbae3f2 cursor: Properly document wl_cursor_image and wl_cursor
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2020-06-05 11:05:20 +00:00
Emmanuel Gil Peyrot
95a3272625 cursor: Use spaces for alignment in the header
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2020-06-05 11:05:20 +00:00
Jan Beich
230885ebb4 cursor/os-compatibility: move resizing into a separate function
Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
2020-02-23 20:42:54 +00:00
Jan Beich
3a3dd0820d cursor: ignore posix_fallocate in shm_pool_resize if not supported by FS
Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
2020-02-23 20:42:54 +00:00
Jan Beich
1283d54dac cursor: posix_fallocate may fail with EINVAL if not supported
ZFS on FreeBSD >= 12.0 returns EINVAL, see
https://svnweb.freebsd.org/changeset/base/325320

Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
2020-02-23 20:42:54 +00:00
Ihor Antonov
8e2199644e os: fallback for unsupported posix_fallocate
Some filesystems do not support fallocate and return EOPNOTSUPP.

On musl-based distros libwayland-cursor exits abruptly which causes the
application to crash. Unlike glibc, musl does not provide a fallback
mechanism for handling unsupported fallocate. Instead, musl developers
argue that application should handle the case of unsupported system
call.

This commit allows falback to ftruncate in case when EOPNOTSUPP
was recieved.

Signed-off-by: Ihor Antonov <ihor@antonovs.family>
2020-01-23 20:32:59 +00:00
Emmanuele Bassi
60acba6e0f
Add Meson build
Meson is a next generation build system, simpler than Autotools and also faster
and more portable. Most importantly, it will make integrating ASan easier in
CI.

The goal is to maintain feature parity of the Meson build with the
Autotools build, until such time when we can drop the latter.

Add a script which generates the desired Doxygen configuration for our various
output formats and executes it using that configuration. This is not something
Meson can or should do.

Fixes: https://gitlab.freedesktop.org/wayland/wayland/issues/80

[daniels: Changed to bump version, use GitLab issues URL, remove header
          checks not used in any code, remove pre-pkg-config Expat
	  support, added missing include paths to wayland-egl and
	  cpp-compile-test, added GitLab CI.
	  Bumped version, removed unnecessary pkg-config paths.]

[daniels: Properly install into mandir/man3 via some gross
          paramaterisation, generate real stamp files.]

Pekka:
- squashed patches
- removed MAKEFLAGS from meson CI
- remove unused PACKAGE* defines
- fix up scanner dependency handling
- instead of host_scanner option, build wayland-scanner twice when cross-compiling
- changed .pc files to match more closely the autotools versions
- reorder doxygen man sources to reduce diff to autotools
- fix pkgconfig.generate syntax warnings (new in Meson)
- bump meson version to 0.47 for configure_file(copy) and run_command(check)
- move doc tool checks into doc/meson.build, needed in more places
- make all doc tools mandatory if building docs
- check dot and doxygen versions
- add build files under doc/publican
- reindent to match Weston Meson style

Simon:
- Remove install arg from configure_file
- Don't build wayland-scanner twice during cross-build
- Fix naming of the threads dependency
- Store tests in dict
- Add missing HAVE_* decls for functions
- Remove unused cc_native variable
- Make doxygen targets a dict
- Make dot_gv a dict
- Use dicts in man_pages
- Make decls use dicts
- Make generated_headers use dicts
- Align Meson version number with autotool's

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
2020-01-10 23:44:38 +01:00
Emmanuel Gil Peyrot
6908c8c85a cursor: Use memfd_create() when available
This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.

It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.

This patch is best viewed with the -w option of git log -p.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
2019-07-21 09:06:43 +00:00
Emil Velikov
2f392daadb cursor: add forward declaration for struct wl_buffer
This makes the header self-contained, since the struct is considered
opaque from waylad-cursor POV.

As we're here move the wl_shm fwd. declaration alongside the others.
Making it easier to read and track.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2017-12-04 19:45:38 +00:00
Tobias Stoeckmann
5d201df72f cursor: Fix heap overflows when parsing malicious files.
It is possible to trigger heap overflows due to an integer overflow
while parsing images.

The integer overflow occurs because the chosen limit 0x10000 for
dimensions is too large for 32 bit systems, because each pixel takes
4 bytes. Properly chosen values allow an overflow which in turn will
lead to less allocated memory than needed for subsequent reads.

See also: https://cgit.freedesktop.org/xorg/lib/libXcursor/commit/?id=4794b5dd34688158fb51a2943032569d3780c4b8
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=103961

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
[Pekka: add link to the corresponding libXcursor commit]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-29 09:45:10 +02:00
Derek Foreman
5c48aac33b cursor: Remove "weston" from anonymous shm filenames
This mildly confused me during some debugging, so I guess it wouldn't
hurt to make the filename more indicative of where it was actually
created.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-11-21 09:58:25 +00:00
Yong Bakos
2b1c1b2d66 (multiple): Include stdint.h
Some headers and source files have been using types such as uint32_t
without explicitly including stdint.h.

Explicitly include stdint.h where appropriate.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-25 18:39:32 -07:00
Bryce Harrington
a8a86010a6 cursor: Update printed license from MIT "X11" to MIT "Expat"
The code generates a cursor-data.h file, with licensing information.
Change this from the MIT "X11" license to MIT "Expat" license for
consistency with the rest of Wayland.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-22 14:50:20 +03:00
Bryce Harrington
1faeb7ff48 xcursor: Change keithp licensed code from X11 to Expat license
The license text for this file mentions Keith Packard specifically,
however it is otherwise identical to all the other MIT X11 licensed code
in Wayland, and so can be changed to the substantially identical MIT
Expat license.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Keith Packard <keithp@keithp.com>
2015-06-12 15:51:38 -07:00
Bryce Harrington
c78a0a62c6 cursor-data.h: Change SuSE licensed code from X11 to Expat
The license text for this file mentions SuSE specifically, however it is
otherwise identical to all the other MIT X11 licensed code in Wayland,
and so can be changed to the substantially identical MIT Expat license.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Keith Packard <keithp@keithp.com>
2015-06-12 15:51:38 -07:00
Bryce Harrington
3540ea2b9f cursor: Update boilerplate from MIT X11 license to MIT Expat license
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-12 15:51:38 -07:00
Michael Vetter
b409c919a2 remove trailing whitespaces
Remove trailing whitespaces because they are not needed and jumping to
the end of al ine should do just that and not jump to the whitespace.
2015-05-15 13:10:15 -07:00
Emmanuel Gil Peyrot
c770b84658 cursor: free the array from which images are linked 2015-03-18 16:01:19 -07:00
Derek Foreman
4908bf0d0f cursor: add wl_cursor_frame_and_duration
It's useful to know how long the current cursor frame should be displayed
so we can wait that long to change it.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-05 09:39:44 +02:00
Hardening
256324773f Add error handling for wl_cursors
This patch adds some error management in wayland cursors

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-01 16:47:04 -07:00
Kristian Høgsberg
267b28887d build: Move cursor Makefile.am into toplevel Makefile.am 2014-03-06 23:15:02 -08:00
U. Artie Eoff
02952d040c xcursor: don't proceed if XcursorImageCreate failed
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00