Commit Graph

54 Commits

Author SHA1 Message Date
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
U. Artie Eoff
d6c6f2977d cursor: check for memory allocation errors
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
7d96da1e65 cursor: free theme->name too
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
Pekka Paalanen
3b3e81f42e cursor: handle running out of buffer space
If posix_fallocate is available, use it to detect when we are running
out of buffer space.

Propagate the failure properly through the various functions, stopping
loading cursors but keeping the cursors that were already successfully
loaded.

This may result in an animated cursor not having all of its images, or a
cursor theme not having all of its cursors. When that happens, the
failure is NOT communicated to the application. Instead, the application
will get NULL from wl_cursor_theme_get_cursor() for a cursor that was
not loaded successfully. If an animated cursor is missing only some
images, the animation is truncated but the cursor is still available.

This patch relies on the commit "os: use posix_fallocate in creating
sharable buffers" for defining HAVE_POSIX_FALLOCATE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:19:45 -08:00
Pekka Paalanen
011b695403 os: use posix_fallocate in creating sharable buffers
If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:18:59 -08:00
Kristian Høgsberg
deddea6549 wayland: Be consistent about #include-guard names
We had a mix of inconsistent names, some of which were non-conformant.
Standardize on all-uppercase-and-underscore naming convention.

https://bugs.freedesktop.org/show_bug.cgi?id=70679
2013-10-21 14:39:06 -07:00
Quentin Glidic
92ca1a0e80 pkgconfig: Use configure provided directories
https://bugs.freedesktop.org/show_bug.cgi?id=57630
2012-11-27 20:35:50 -05:00
Kristian Høgsberg
bdd272f024 Move ARRAY_LENGTH out of public headers
Exporting unprefixed symbols is a pretty bad idea so don't do that.
Instea of redefining it WL_ARRAY_LENGTH, we just move the define to
our private header.  The scanner generates code that uses ARRAY_LENGTH,
but we can just make it count the number elements and emit an integer
constant instead.
2012-10-19 17:08:38 -04:00
Matt Roper
0371668dcc Ensure cursor_data.c is included in distribution tarballs
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2012-10-09 23:42:52 -04:00
Rob Bradford
0201708773 xcursor: Fix allocation based on string length
strlen() doesn't include the terminating NUL. Therefore when allocating a
block of memory to hold something equivalent to the length of the string we
must increment to take the NUL byte into consideration.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
2012-10-09 23:01:23 -04:00
Philipp Brüschweiler
7fafa994a4 cursor: add cursor.pcf and extraction program 2012-09-10 21:05:14 -04:00
Philipp Brüschweiler
9ce9336c57 cursor: Add a default cursor theme
This theme is loaded when the specified cursor theme can not be found.

These cursors are extracted from the xorg sources and transformed into
raw ARGB data by a small helper program (commited separately).
2012-09-10 21:04:55 -04:00
Christopher Michael
b57694ca0e Add support for X cursor themes.
This patch adds a few more directories to search for xcursor themes.

Along with the weston patch, this adds the ability to configure weston
to use an X11 cursor theme. Previously, wayland cursor would just look
in the icons and pixmaps directories for cursor images to load. This
adds the ability to also search in the x cursors directory.
2012-08-13 11:02:56 -04:00
Dima Ryazanov
31c0258ff1 Don't skip the first directory entry when reading cursors.
I end up missing the "bottom_right_corner" cursor.
2012-07-26 22:04:32 -04:00
Pekka Paalanen
52e6dc71be cursor: fix fd leak and a segfault
- don't leak fd in shm_pool_destroy()
- return NULL from wl_cursor_theme_load() if pool fails

Tha last one fixes a segfault, when shm_pool_create() has failed.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-07-10 14:11:00 -04:00
Pekka Paalanen
a88a4386cb cursor: use os_create_anonymous_file()
Copy the implementation of os_create_anonymous_file() here from weston,
so we can use it instead of hardcoding a path to /tmp.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-07-10 14:08:59 -04:00
Martin Olsson
00902b3815 wayland-cursor: Add error handling for shm_pool_create() 2012-07-09 17:59:08 -04:00
Ander Conselvan de Oliveira
2261007953 wayland-cursor: Plug leak of filename on load_all_cursors_from_dir() 2012-06-19 11:36:31 -04:00
Daniel Stone
61260854ec Xcursor: Don't ignore unknown file types
XFS doesn't return the file type with opendir(), and instead only
returns it when you stat() the file itself.  c66f2602 introduced a check
to ensure that only files and symlinks were loaded, while not checking
for DT_UNKNOWN.  Properly handle DT_UNKNOWN by just proceeding anyway.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-18 15:15:11 -04:00
Ander Conselvan de Oliveira
6b861f7b4d cursor: Add function for calculating current frame in cursor animation
Given a pointer to struct wl_cursor and an elapsed time in ms.,
wl_cursor_frame() will return the index of the cursor image the should
be displayed.
2012-06-15 10:53:58 -04:00
Ander Conselvan de Oliveira
dd8891be36 wayland-cursor: add an option that changes the cursor theme directory
Some distros (e.g. gentoo) install cursor themes in non-standard
directories. Add option --with-icondir to configure.sh that sets the
directory in which to look for cursors.
2012-06-08 12:50:42 -04:00
Daniel Stone
32add9c6e6 cursor: Fix warning with objdir != srcdir build
Make sure we find the right include paths.

krh: Edited to use $(top_builddir)

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 14:00:41 -04:00
Pekka Paalanen
693e5983f4 build: add uninstalled pkg-config files
Required for building apps against wayland libraries that have not been
installed.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-29 10:09:59 -04:00
Rob Bradford
e4efef869e cursor: Link libwayland-cursor to libwayland-client
LDADD is only used when linking programs not libraries.

Spotted-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-05-29 10:07:30 -04:00
Ander Conselvan de Oliveira
c66f26024b wayland-cursor: load all cursors from a theme on wl_cursor_theme_load 2012-05-25 23:06:27 -04:00