Commit Graph

31 Commits

Author SHA1 Message Date
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
Ander Conselvan de Oliveira
f779c57be2 wayland-cursor: remove enum wl_cursor_type
Defining a list of all cursors a theme, client or toolkit should have
is not the purpose of libwayland-cursor. The cursor type enum existed
for making lookups faster, but this kind of optmization belongs in the
toolkits.
2012-05-25 23:06:15 -04:00
Yan Wang
d860f0cbec Wayland: Add missing extern "C"
Add extern "C" macro definition for C++.
2012-05-23 09:32:03 -04:00
Kristian Høgsberg
5030af7635 cursor: Fix unsigned/signed comparisons 2012-05-22 22:41:21 -04:00
Ander Conselvan de Oliveira
775002c6c0 Introduce libwayland-cursor, a cursor helper library
The purpose of this library is to be the equivalent of libXcursor in
the X world. This library is compatible with X cursor themes and loads
them directly into an shm pool making it easy for the clients to get
buffer for each cursor image.

The code for handling the X cursor theme was taken from libXcursor. The
files cursor/xcursor.[ch] are a stripped down version of that library
containing only the interfaces necessary for implementing the wayland
counterpart.
2012-05-22 15:20:13 -04:00