Makefile.am | 2 configure.ac | 7 cursor/os-compatibility.c | 19 ++ cursor/wayland-cursor.c | 67 +++++++-- cursor/xcursor.h | 4 debian/changelog | 6 debian/libwayland-client0.symbols | 4 debian/libwayland-dev.install | 1 debian/libwayland-server0.symbols | 4 debian/patches/configure-ac-update.patch | 36 +++++ debian/patches/series | 1 doc/doxygen/Makefile.am | 3 protocol/.gitignore | 1 protocol/Makefile.am | 15 +- protocol/wayland.dtd | 29 ++++ protocol/wayland.xml | 219 ++++++++++++++++++++++++++++++ src/Makefile.am | 4 src/connection.c | 100 ++++++++++++- src/scanner.c | 135 ++++++++++++------ src/wayland-client.c | 222 +++++++++++++++++++++++-------- src/wayland-client.h | 12 + src/wayland-egl.h | 4 src/wayland-server.c | 129 +++++++++++++++++- src/wayland-server.h | 10 + src/wayland-shm.c | 197 +++++++++++++++++++++++++++ 25 files changed, 1087 insertions(+), 144 deletions(-)
New commits: commit 412171820121bdd495816e2c2f70c6fc654aaa6d Author: Héctor Orón Martínez <zu...@debian.org> Date: Sat Jan 18 18:48:53 2014 +0100 Update configure.ac for release 1.3.92 Signed-off-by: Héctor Orón Martínez <zu...@debian.org> diff --git a/debian/patches/configure-ac-update.patch b/debian/patches/configure-ac-update.patch new file mode 100644 index 0000000..9f017af --- /dev/null +++ b/debian/patches/configure-ac-update.patch @@ -0,0 +1,36 @@ +Description: <short summary of the patch> + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + wayland (1.3.92-1) unstable; urgency=medium + . + * New upstream release (1.3.92) +Author: Hector Oron <zu...@debian.org> + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: <vendor|upstream|other>, <url of original patch> +Bug: <url in upstream bugtracker> +Bug-Debian: http://bugs.debian.org/<bugnumber> +Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> +Forwarded: <no|not-needed|url proving that it has been forwarded> +Reviewed-By: <name and email of someone who approved the patch> +Last-Update: <YYYY-MM-DD> + +--- wayland-1.3.92.orig/configure.ac ++++ wayland-1.3.92/configure.ac +@@ -2,7 +2,7 @@ AC_PREREQ([2.64]) + + m4_define([wayland_major_version], [1]) + m4_define([wayland_minor_version], [3]) +-m4_define([wayland_micro_version], [91]) ++m4_define([wayland_micro_version], [92]) + m4_define([wayland_version], + [wayland_major_version.wayland_minor_version.wayland_micro_version]) + diff --git a/debian/patches/series b/debian/patches/series index 9bf2d52..a244795 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ # placeholder. +configure-ac-update.patch commit 2f90ef989a2295c46ec116d62489950a7ce079b5 Author: Héctor Orón Martínez <zu...@debian.org> Date: Sat Jan 18 18:48:28 2014 +0100 debian/libwayland-dev.install: install wayland.dtd Signed-off-by: Héctor Orón Martínez <zu...@debian.org> diff --git a/debian/libwayland-dev.install b/debian/libwayland-dev.install index ced3154..7bfe127 100644 --- a/debian/libwayland-dev.install +++ b/debian/libwayland-dev.install @@ -23,3 +23,4 @@ usr/share/wayland/wayland-scanner.mk # Documentation usr/share/wayland/wayland.xml usr/share/doc/wayland/wayland.xml +usr/share/wayland/wayland.dtd usr/share/doc/wayland/wayland.dtd commit d4805e10f74a8ef7d2d1de2e19f204c68c6941d1 Author: Héctor Orón Martínez <zu...@debian.org> Date: Sat Jan 18 18:48:04 2014 +0100 Update symbols Signed-off-by: Héctor Orón Martínez <zu...@debian.org> diff --git a/debian/libwayland-client0.symbols b/debian/libwayland-client0.symbols index d83d394..7401d54 100644 --- a/debian/libwayland-client0.symbols +++ b/debian/libwayland-client0.symbols @@ -58,6 +58,8 @@ libwayland-client.so.0 libwayland-client0 #MINVER# wl_proxy_get_user_data@Base 1.0.2 wl_proxy_marshal@Base 1.0.2 wl_proxy_marshal_array@Base 1.3.0 + wl_proxy_marshal_array_constructor@Base 1.3.92 + wl_proxy_marshal_constructor@Base 1.3.92 wl_proxy_set_queue@Base 1.0.2 wl_proxy_set_user_data@Base 1.0.2 wl_region_interface@Base 1.0.2 @@ -67,5 +69,7 @@ libwayland-client.so.0 libwayland-client0 #MINVER# wl_shell_surface_interface@Base 1.0.2 wl_shm_interface@Base 1.0.2 wl_shm_pool_interface@Base 1.0.2 + wl_subcompositor_interface@Base 1.3.92 + wl_subsurface_interface@Base 1.3.92 wl_surface_interface@Base 1.0.2 wl_touch_interface@Base 1.0.2 diff --git a/debian/libwayland-server0.symbols b/debian/libwayland-server0.symbols index 369bb10..27cc810 100644 --- a/debian/libwayland-server0.symbols +++ b/debian/libwayland-server0.symbols @@ -102,7 +102,9 @@ libwayland-server.so.0 libwayland-server0 #MINVER# wl_seat_interface@Base 1.0.2 wl_shell_interface@Base 1.0.2 wl_shell_surface_interface@Base 1.0.2 + wl_shm_buffer_begin_access@Base 1.3.92 wl_shm_buffer_create@Base 1.0.2 + wl_shm_buffer_end_access@Base 1.3.92 wl_shm_buffer_get@Base 1.2.0 wl_shm_buffer_get_data@Base 1.0.2 wl_shm_buffer_get_format@Base 1.0.2 @@ -111,5 +113,7 @@ libwayland-server.so.0 libwayland-server0 #MINVER# wl_shm_buffer_get_width@Base 1.0.2 wl_shm_interface@Base 1.0.2 wl_shm_pool_interface@Base 1.0.2 + wl_subcompositor_interface@Base 1.3.92 + wl_subsurface_interface@Base 1.3.92 wl_surface_interface@Base 1.0.2 wl_touch_interface@Base 1.0.2 commit 4a0c6c0e02c7cb9049b131437f9c991b1bf845bc Author: Héctor Orón Martínez <zu...@debian.org> Date: Sat Jan 18 18:17:37 2014 +0100 Bump changelog Signed-off-by: Héctor Orón Martínez <zu...@debian.org> diff --git a/debian/changelog b/debian/changelog index 25d642a..40cc951 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wayland (1.3.92-1) unstable; urgency=medium + + * New upstream release (1.3.92) + + -- Hector Oron <zu...@debian.org> Sat, 18 Jan 2014 18:16:17 +0100 + wayland (1.3.0-1) unstable; urgency=low [ Timo Aaltonen ] commit c102c20f01c84abde71b7f208aae9b232226da1e Author: chi ding <chi.d...@mobica.com> Date: Thu Dec 5 14:28:53 2013 +0100 Fix buffer overflow when serializing a closure object Here is the JIRA page of this issue https://bugs.tizen.org/jira/browse/TIVI-1889 Change-Id: I773a6d2d8f6fd02ff10c92450db1fa8a69544219 Signed-off-by: Chi Ding <chi.d...@mobica.com> Closes: https://bugs.freedesktop.org/show_bug.cgi?id=65186 diff --git a/src/connection.c b/src/connection.c index 1d8b61b..d05341a 100644 --- a/src/connection.c +++ b/src/connection.c @@ -962,6 +962,57 @@ copy_fds_to_connection(struct wl_closure *closure, return 0; } + +static uint32_t +buffer_size_for_closure(struct wl_closure *closure) +{ + const struct wl_message *message = closure->message; + int i, count; + struct argument_details arg; + const char *signature; + uint32_t size, buffer_size = 0; + + signature = message->signature; + count = arg_count_for_signature(signature); + for (i = 0; i < count; i++) { + signature = get_next_argument(signature, &arg); + + switch (arg.type) { + case 'h': + break; + case 'u': + case 'i': + case 'f': + case 'o': + case 'n': + buffer_size++; + break; + case 's': + if (closure->args[i].s == NULL) { + buffer_size++; + break; + } + + size = strlen(closure->args[i].s) + 1; + buffer_size += 1 + DIV_ROUNDUP(size, sizeof(uint32_t)); + break; + case 'a': + if (closure->args[i].a == NULL) { + buffer_size++; + break; + } + + size = closure->args[i].a->size; + buffer_size += (1 + DIV_ROUNDUP(size, sizeof(uint32_t))); + break; + default: + break; + } + } + + return buffer_size + 2; +} + static int serialize_closure(struct wl_closure *closure, uint32_t *buffer, size_t buffer_count) @@ -1055,33 +1106,57 @@ overflow: int wl_closure_send(struct wl_closure *closure, struct wl_connection *connection) { - uint32_t buffer[256]; int size; + uint32_t buffer_size; + uint32_t *buffer; + int result; if (copy_fds_to_connection(closure, connection)) return -1; - size = serialize_closure(closure, buffer, 256); - if (size < 0) + buffer_size = buffer_size_for_closure(closure); + buffer = malloc(buffer_size * sizeof buffer[0]); + if (buffer == NULL) + return -1; + + size = serialize_closure(closure, buffer, buffer_size); + if (size < 0) { + free(buffer); return -1; + } + + result = wl_connection_write(connection, buffer, size); + free(buffer); - return wl_connection_write(connection, buffer, size); + return result; } int wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection) { - uint32_t buffer[256]; int size; + uint32_t buffer_size; + uint32_t *buffer; + int result; if (copy_fds_to_connection(closure, connection)) return -1; - size = serialize_closure(closure, buffer, 256); - if (size < 0) + buffer_size = buffer_size_for_closure(closure); + buffer = malloc(buffer_size * sizeof buffer[0]); + if (buffer == NULL) + return -1; + + size = serialize_closure(closure, buffer, buffer_size); + if (size < 0) { + free(buffer); return -1; + } + + result = wl_connection_queue(connection, buffer, size); + free(buffer); - return wl_connection_queue(connection, buffer, size); + return result; } void commit cd0dccd01e16fa404e03974d30ded3aebdb1c4bc Author: Adrian Negreanu <adrian.m.negre...@intel.com> Date: Tue Dec 17 13:48:54 2013 +0200 scanner: set errno=0 before strtol POSIX says to set errno=0 before calling strtol since the return value alne cannot tell a failure. on ubuntu armel I get: ../src/wayland-scanner client-header < ../../protocol/wayland.xml > wayland-client-protocol.h <stdin>:1188: error: invalid integer (2) Signed-off-by: Adrian Negreanu <adrian.m.negre...@intel.com> diff --git a/src/scanner.c b/src/scanner.c index a030181..243ddfd 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -399,6 +399,7 @@ start_element(void *data, const char *element_name, const char **atts) message->destructor = 0; if (since != NULL) { + errno = 0; version = strtol(since, &end, 0); if (errno == EINVAL || end == since || *end != '\0') fail(&ctx->loc, commit 01bde6319f49ba9c943b1edad32efa10336b4685 Author: Kristian Høgsberg <k...@bitplanet.net> Date: Mon Dec 16 23:51:12 2013 -0800 configure.ac: Bump version to 1.3.91 for the alpha release diff --git a/configure.ac b/configure.ac index b289567..8935953 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.64]) m4_define([wayland_major_version], [1]) m4_define([wayland_minor_version], [3]) -m4_define([wayland_micro_version], [90]) +m4_define([wayland_micro_version], [91]) m4_define([wayland_version], [wayland_major_version.wayland_minor_version.wayland_micro_version]) commit 1a58c7f2115a982a9156779bb6141acd303ddef5 Author: Kristian Høgsberg <k...@bitplanet.net> Date: Mon Dec 9 15:49:48 2013 -0800 client: Handle EINTR in wl_display_dispatch_queue() Restart the poll() if we take a signal. This is easily triggered in an application that ends up blocking in eglSwapBuffers(), and causes EGL to fail to allocate a back buffer. diff --git a/src/wayland-client.c b/src/wayland-client.c index 7503ca0..363d5dd 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1313,7 +1313,11 @@ wl_display_dispatch_queue(struct wl_display *display, pfd[0].fd = display->fd; pfd[0].events = POLLIN; - if (poll(pfd, 1, -1) == -1) { + do { + ret = poll(pfd, 1, -1); + } while (ret == -1 && errno == EINTR); + + if (ret == -1) { wl_display_cancel_read(display); return -1; } commit 09877f3231623cca65ca08f3a3a694b2af495c80 Author: Jonas Ådahl <jad...@gmail.com> Date: Mon Dec 9 22:35:22 2013 +0100 doc: Fix spelling of parameters Signed-off-by: Jonas Ådahl <jad...@gmail.com> diff --git a/src/wayland-client.c b/src/wayland-client.c index ab79b7b..7503ca0 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -427,7 +427,7 @@ create_outgoing_proxy(struct wl_proxy *proxy, const struct wl_message *message, * \param proxy The proxy object * \param opcode Opcode of the request to be sent * \param args Extra arguments for the given request - * \param iterface The interface to use for the new proxy + * \param interface The interface to use for the new proxy * * Translates the request given by opcode and the extra arguments into the * wire format and write it to the connection buffer. This version takes an @@ -519,7 +519,7 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) * * \param proxy The proxy object * \param opcode Opcode of the request to be sent - * \param iterface The interface to use for the new proxy + * \param interface The interface to use for the new proxy * \param ... Extra arguments for the given request * \return A new wl_proxy for the new_id argument or NULL on error * commit c30208f0b7ae964ad14546936d8320b61a506653 Author: Jonas Ådahl <jad...@gmail.com> Date: Mon Dec 9 22:35:21 2013 +0100 doc: Remove incorrect docmentation The documentation was about wl_client_get_object(), not about wl_resource_get_client(). Signed-off-by: Jonas Ådahl <jad...@gmail.com> diff --git a/src/wayland-server.c b/src/wayland-server.c index 80e76e1..1459e09 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -592,17 +592,6 @@ wl_resource_find_for_client(struct wl_list *list, struct wl_client *client) return NULL; } -/** Look up an object in the client name space - * - * \param client The client object - * \param id The object id - * \return The object or NULL if there is not object for the given ID - * - * This looks up an object in the client object name space by its - * object ID. - * - * \memberof wl_client - */ WL_EXPORT struct wl_client * wl_resource_get_client(struct wl_resource *resource) { commit 1521c62a31664d7372f5a987bd7f34574bd0c7d6 Author: Neil Roberts <n...@linux.intel.com> Date: Wed Dec 4 16:58:39 2013 -0800 client: Make wl_proxy_set_queue() with NULL revert to default queue This will be useful in order to implement the EGL_WL_create_wayland_buffer_from_image extension. The buffers created within Mesa's Wayland platform are created using the the wl_drm object as a proxy factory which means they will be set to use Mesa's internal event queue. However, these buffers will be owned by the client application so they ideally need to use the default event loop. This function provides a way to set the proxy's event queue back to the default. krh: Edited from Neils original patch to just use wl_proxy_set_queue() with a NULL argument instead of introducing a new function. diff --git a/src/wayland-client.c b/src/wayland-client.c index 1486b73..ab79b7b 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1572,7 +1572,10 @@ wl_proxy_get_class(struct wl_proxy *proxy) WL_EXPORT void wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue) { - proxy->queue = queue; + if (queue) + proxy->queue = queue; + else + proxy->queue = &proxy->display->queue; } WL_EXPORT void commit 3b3e81f42e0bf05e606f40ac0145977766283548 Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Fri Nov 29 17:47:09 2013 +0200 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.paala...@collabora.co.uk> diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c index 25e51c2..3dadbdd 100644 --- a/cursor/wayland-cursor.c +++ b/cursor/wayland-cursor.c @@ -20,6 +20,7 @@ * OF THIS SOFTWARE. */ +#include "config.h" #include "xcursor.h" #include "wayland-cursor.h" #include "wayland-client.h" @@ -28,6 +29,8 @@ #include <string.h> #include <unistd.h> #include <sys/mman.h> +#include <fcntl.h> +#include <errno.h> #include "os-compatibility.h" @@ -79,6 +82,12 @@ shm_pool_resize(struct shm_pool *pool, int size) if (ftruncate(pool->fd, size) < 0) return 0; +#ifdef HAVE_POSIX_FALLOCATE + errno = posix_fallocate(pool->fd, 0, size); + if (errno != 0) + return 0; +#endif + wl_shm_pool_resize(pool->pool, size); munmap(pool->data, pool->size); @@ -199,21 +208,15 @@ wl_cursor_create_from_data(struct cursor_metadata *metadata, cursor->cursor.image_count = 1; cursor->cursor.images = malloc(sizeof *cursor->cursor.images); - if (!cursor->cursor.images) { - free(cursor); - return NULL; - } + if (!cursor->cursor.images) + goto err_free_cursor; cursor->cursor.name = strdup(metadata->name); cursor->total_delay = 0; image = malloc(sizeof *image); - if (!image) { - free(cursor->cursor.name); - free(cursor->cursor.images); - free(cursor); - return NULL; - } + if (!image) + goto err_free_images; cursor->cursor.images[0] = (struct wl_cursor_image *) image; image->theme = theme; @@ -226,10 +229,25 @@ wl_cursor_create_from_data(struct cursor_metadata *metadata, size = metadata->width * metadata->height * sizeof(uint32_t); image->offset = shm_pool_allocate(theme->pool, size); + + if (image->offset < 0) + goto err_free_image; + memcpy(theme->pool->data + image->offset, cursor_data + metadata->offset, size); return &cursor->cursor; + +err_free_image: + free(image); + +err_free_images: + free(cursor->cursor.name); + free(cursor->cursor.images); + +err_free_cursor: + free(cursor); + return NULL; } static void @@ -240,12 +258,17 @@ load_default_theme(struct wl_cursor_theme *theme) free(theme->name); theme->name = strdup("default"); - theme->cursor_count = ARRAY_LENGTH(cursor_metadata);; + theme->cursor_count = ARRAY_LENGTH(cursor_metadata); theme->cursors = malloc(theme->cursor_count * sizeof(*theme->cursors)); - for (i = 0; i < theme->cursor_count; ++i) + for (i = 0; i < theme->cursor_count; ++i) { theme->cursors[i] = wl_cursor_create_from_data(&cursor_metadata[i], theme); + + if (theme->cursors[i] == NULL) + break; + } + theme->cursor_count = i; } static struct wl_cursor * @@ -260,7 +283,6 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images, if (!cursor) return NULL; - cursor->cursor.image_count = images->nimage; cursor->cursor.images = malloc(images->nimage * sizeof cursor->cursor.images[0]); if (!cursor->cursor.images) { @@ -273,7 +295,6 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images, for (i = 0; i < images->nimage; i++) { image = malloc(sizeof *image); - cursor->cursor.images[i] = (struct wl_cursor_image *) image; image->theme = theme; image->buffer = NULL; @@ -283,13 +304,27 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images, image->image.hotspot_x = images->images[i]->xhot; image->image.hotspot_y = images->images[i]->yhot; image->image.delay = images->images[i]->delay; - cursor->total_delay += image->image.delay; - /* copy pixels to shm pool */ size = image->image.width * image->image.height * 4; image->offset = shm_pool_allocate(theme->pool, size); + if (image->offset < 0) { + free(image); + break; + } + + /* copy pixels to shm pool */ memcpy(theme->pool->data + image->offset, images->images[i]->pixels, size); + cursor->total_delay += image->image.delay; + cursor->cursor.images[i] = (struct wl_cursor_image *) image; + } + cursor->cursor.image_count = i; + + if (cursor->cursor.image_count == 0) { + free(cursor->cursor.name); + free(cursor->cursor.images); + free(cursor); + return NULL; } return &cursor->cursor; commit 011b6954031a25de8d9eb39631b6837553bb3cfb Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Fri Nov 29 17:47:08 2013 +0200 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.paala...@collabora.co.uk> diff --git a/configure.ac b/configure.ac index f8be456..b289567 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,7 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(GCC_CFLAGS) -AC_CHECK_FUNCS([accept4 mkostemp]) +AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate]) AC_CHECK_DECL(SFD_CLOEXEC,[], [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile wayland")], diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c index 418b0d3..0c41242 100644 --- a/cursor/os-compatibility.c +++ b/cursor/os-compatibility.c @@ -90,6 +90,12 @@ create_tmpfile_cloexec(char *tmpname) * The file is suitable for buffer sharing between processes by * transmitting the file descriptor over Unix sockets using the * SCM_RIGHTS methods. + * + * If the C library implements posix_fallocate(), it is used to + * guarantee that disk space is available for the file at the + * given size. If disk space is insufficent, errno is set to ENOSPC. + * If posix_fallocate() is not supported, program may receive + * SIGBUS on accessing mmap()'ed file contents instead. */ int os_create_anonymous_file(off_t size) @@ -98,6 +104,7 @@ os_create_anonymous_file(off_t size) const char *path; char *name; int fd; + int ret; path = getenv("XDG_RUNTIME_DIR"); if (!path) { @@ -119,10 +126,20 @@ os_create_anonymous_file(off_t size) if (fd < 0) return -1; - if (ftruncate(fd, size) < 0) { +#ifdef HAVE_POSIX_FALLOCATE + ret = posix_fallocate(fd, 0, size); + if (ret != 0) { + close(fd); + errno = ret; + return -1; + } +#else + ret = ftruncate(fd, size); + if (ret < 0) { close(fd); return -1; } +#endif return fd; } commit 5a019e38a1316a31072a9cb6de8da4377f3cfad5 Author: Kristian Høgsberg <k...@bitplanet.net> Date: Sat Nov 23 12:24:26 2013 -0800 Add -pthread to AM_CFLAGS to do the right thing when using threads https://bugs.freedesktop.org/show_bug.cgi?id=71633 diff --git a/src/Makefile.am b/src/Makefile.am index fb2df1c..15f44a5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,7 +36,7 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = wayland-client.pc wayland-server.pc AM_CPPFLAGS = $(FFI_CFLAGS) -AM_CFLAGS = $(GCC_CFLAGS) +AM_CFLAGS = $(GCC_CFLAGS) -pthread protocoldir = $(top_srcdir)/protocol commit 360dca517a8ae58f9709420b0570b4e36a1ffa3f Author: Lubomir Rintel <lkund...@v3.sk> Date: Sat Nov 16 14:31:03 2013 +0100 connection: Error out if file descriptor was not received Otherwise the tail of fds_in buffer would just shift beyond the beginning. That confuses the actual request handler and results in a crash further on due to corrupted tail. Signed-off-by: Lubomir Rintel <lkund...@v3.sk> diff --git a/src/connection.c b/src/connection.c index 451b93e..1d8b61b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -744,6 +744,15 @@ wl_connection_demarshal(struct wl_connection *connection, p = next; break; case 'h': + if (connection->fds_in.tail == connection->fds_in.head) { + printf("file descriptor expected, " + "object (%d), message %s(%s)\n", + closure->sender_id, message->name, + message->signature); + errno = EINVAL; + goto err; + } + wl_buffer_copy(&connection->fds_in, &fd, sizeof fd); connection->fds_in.tail += sizeof fd; closure->args[i].h = fd; commit 40d057f2c90eaeffd6185078b25a0e0ff861f2a8 Author: Jasper St. Pierre <jstpie...@mecheye.net> Date: Tue Nov 12 21:44:37 2013 -0500 wayland-server: Improve error messages for bad globals A bug in Weston's toytoolkit gave me an hour of debugging headaches. Improve the error messages that we send if a client requests an invalid global, either by name or by version. diff --git a/src/wayland-server.c b/src/wayland-server.c index e04d2f4..80e76e1 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -701,11 +701,15 @@ registry_bind(struct wl_client *client, if (global->name == name) break; - if (&global->link == &display->global_list || - global->version < version) + if (&global->link == &display->global_list) wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid global %d", name); + "invalid global %s (%d)", interface, name); + else if (global->version < version) + wl_resource_post_error(resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid version for global %s (%d): have %d, wanted %d", + interface, name, global->version, version); else global->bind(client, global->data, version, id); } commit 148478323fa67c8a30481f4fd8d3c06ea9fb258e Author: Jasper St. Pierre <jstpie...@mecheye.net> Date: Tue Nov 12 21:44:36 2013 -0500 Update .gitignore for protocol/ diff --git a/protocol/.gitignore b/protocol/.gitignore index a67e944..78f49d2 100644 --- a/protocol/.gitignore +++ b/protocol/.gitignore @@ -1 +1,2 @@ wayland.html +.wayland.xml.valid commit 853c24e6998f747150e4233cf41bfa8268964cc2 Author: Kristian Høgsberg <k...@bitplanet.net> Date: Thu Nov 14 21:29:06 2013 -0800 client: Introduce functions to allocate and marshal proxies atomically The server requires clients to only allocate one ID ahead of the previously highest ID in order to keep the ID range tight. Failure to do so will make the server close the client connection. However, the way we allocate new IDs is racy. The generated code looks like: new_proxy = wl_proxy_create(...); wl_proxy_marshal(proxy, ... new_proxy, ...); If two threads do this at the same time, there's a chance that thread A will allocate a proxy, then get pre-empted by thread B which then allocates a proxy and then passes it to wl_proxy_marshal(). The ID for thread As proxy will be one higher that the currently highest ID, but the ID for thread Bs proxy will be two higher. But since thread B prempted thread A before it could send its new ID, B will send its new ID first, the server will see the ID from thread Bs proxy first, and will reject it. We fix this by introducing wl_proxy_marshal_constructor(). This function is identical to wl_proxy_marshal(), except that it will allocate a wl_proxy for NEW_ID arguments and send it, all under the display mutex. By introducing a new function, we maintain backwards compatibility with older code from the generator, and make sure that the new generated code has an explicit dependency on a new enough libwayland-client.so. A virtual Wayland merit badge goes to Kalle Vahlman, who tracked this down and analyzed the issue. Reported-by: Kalle Vahlman <kalle.vahl...@movial.com> diff --git a/src/Makefile.am b/src/Makefile.am index 4226f63..fb2df1c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,7 @@ libwayland_server_la_SOURCES = \ event-loop.c libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-util.la -lrt -lm -libwayland_client_la_LDFLAGS = -version-info 1:0:1 +libwayland_client_la_LDFLAGS = -version-info 2:0:2 libwayland_client_la_SOURCES = \ wayland-protocol.c \ wayland-client.c diff --git a/src/scanner.c b/src/scanner.c index 9624618..a030181 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -699,31 +699,34 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) "{\n"); if (ret) { printf("\tstruct wl_proxy *%s;\n\n" - "\t%s = wl_proxy_create(" - "(struct wl_proxy *) %s,\n", - ret->name, ret->name, interface->name); + "\t%s = wl_proxy_marshal_constructor(" + "(struct wl_proxy *) %s,\n" + "\t\t\t %s_%s, ", + ret->name, ret->name, + interface->name, + interface->uppercase_name, + m->uppercase_name); + if (ret->interface_name == NULL) - printf("\t\t\t interface);\n"); + printf("interface"); else - printf("\t\t\t &%s_interface);\n", - ret->interface_name); - - printf("\tif (!%s)\n" - "\t\treturn NULL;\n\n", - ret->name); + printf("&%s_interface", ret->interface_name); + } else { + printf("\twl_proxy_marshal((struct wl_proxy *) %s,\n" + "\t\t\t %s_%s", + interface->name, + interface->uppercase_name, + m->uppercase_name); } - printf("\twl_proxy_marshal((struct wl_proxy *) %s,\n" - "\t\t\t %s_%s", - interface->name, - interface->uppercase_name, - m->uppercase_name); - wl_list_for_each(a, &m->arg_list, link) { - if (a->type == NEW_ID && a->interface_name == NULL) - printf(", interface->name, version"); - printf(", "); - printf("%s", a->name); + if (a->type == NEW_ID) { + if (a->interface_name == NULL) + printf(", interface->name, version"); + printf(", NULL"); + } else { + printf(", %s", a->name); + } } printf(");\n"); diff --git a/src/wayland-client.c b/src/wayland-client.c index e92317a..1486b73 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -194,6 +194,29 @@ wl_display_create_queue(struct wl_display *display) return queue; } +static struct wl_proxy * +proxy_create(struct wl_proxy *factory, const struct wl_interface *interface) +{ + struct wl_proxy *proxy; + struct wl_display *display = factory->display; + + proxy = malloc(sizeof *proxy); + if (proxy == NULL) + return NULL; + + proxy->object.interface = interface; + proxy->object.implementation = NULL; + proxy->dispatcher = NULL; + proxy->display = display; + proxy->queue = factory->queue; + proxy->flags = 0; + proxy->refcount = 1; + + proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy); + + return proxy; +} + /** Create a proxy object with a given interface * -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1w4a6u-0001us...@moszumanska.debian.org