diff -Nru wayland-0.94.90+git20120630.9de9e39f/ChangeLog wayland-0.94.90+git20120712.52e6dc71/ChangeLog --- wayland-0.94.90+git20120630.9de9e39f/ChangeLog 2012-06-30 07:34:08.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/ChangeLog 2012-07-12 17:06:10.000000000 +0000 @@ -1,9 +1,255 @@ -commit 6aff752626906907a3981cd4660941fca2a94b62 +commit d28702635314d8c69305d0a67d548787efbba38a Author: Rico Tzschichholz -Date: Sat Jun 30 09:33:53 2012 +0200 +Date: Thu Jul 12 19:05:54 2012 +0200 Add debian tree from origin/ubuntu +commit 52e6dc71becf4ee7f473f8af79fd71f95b6889c0 +Author: Pekka Paalanen +Date: Tue Jul 10 13:05:03 2012 +0300 + + 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 + +commit a88a4386cbf5f3a627345f12683210c3b81b292b +Author: Pekka Paalanen +Date: Tue Jul 10 13:05:02 2012 +0300 + + 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 + +commit 9326498d03c9c4b0120082387b623ad70b4205c7 +Author: Pekka Paalanen +Date: Tue Jul 10 13:05:01 2012 +0300 + + server: fix wl_seat_set_keyboard + + This makes wl_seat_set_keyboard similar to wl_seat_set_pointer in that + it's a no-op, if you try to set keyboard to NULL when it already is + NULL, instead of refusing to set it to NULL ever. + + Signed-off-by: Pekka Paalanen + +commit 23bf48063ff6d3150cee99715f0f1b48ebd4a82e +Author: Pekka Paalanen +Date: Tue Jul 10 13:05:00 2012 +0300 + + server: add lose_touch_focus() + + Just like wl_keyboard and wl_pointer, add a signal handler for losing + touch focus. + + Signed-off-by: Pekka Paalanen + +commit e7e1296682b550349832d8922d688014dae7f968 +Author: Robert Ancell +Date: Thu Jul 5 16:31:29 2012 +1200 + + scanner: Include weston-client.h as the inline functions require it + +commit b4aff6b79f80cf8110de346e527b2288903a839f +Author: Kristian Høgsberg +Date: Mon Jul 9 21:50:39 2012 -0400 + + wayland-shm: Add return before we hit the error clean-up path + + Regression in c94c0946db694ec29b5aebb94a8be0501bacfbc7 + +commit dba322c1c0a7e09b4ca616c53762865921f77526 +Author: Martin Olsson +Date: Mon Jul 9 18:22:05 2012 +0200 + + Fixup source comment in wayland-util.h and fix typo in TODO + +commit fc0c2e04c50c2ba60272270d1a71ec57a42e7b5b +Author: Martin Olsson +Date: Mon Jul 9 15:50:39 2012 +0200 + + doc: fix some typos in documentation + +commit 84bac043e1c6313f7b8812a31ddb179b3f7933d5 +Author: Ander Conselvan de Oliveira +Date: Mon Jul 9 13:15:20 2012 +0300 + + protocol: Add missing allow-null to data_device.enter data_offer field + + Fixes bug 51889. + +commit c94c0946db694ec29b5aebb94a8be0501bacfbc7 +Author: Martin Olsson +Date: Mon Jul 9 11:35:57 2012 +0200 + + shm: Plug leak in shm_create_pool() + +commit 53bb40170475a9eaef23c700c5d1f6fac8b3510f +Author: Martin Olsson +Date: Mon Jul 9 11:35:56 2012 +0200 + + server: Don't crash for wl_seat_set_touch(seat, NULL) + +commit e760ec9fa97c3776d8db47d26ad93b1bfd09fc6d +Author: Martin Olsson +Date: Mon Jul 9 11:35:55 2012 +0200 + + scanner: Plug memory leak in end_element() + +commit 00902b38151d6b4373584eb52dc44143825ef88f +Author: Martin Olsson +Date: Mon Jul 9 11:35:54 2012 +0200 + + wayland-cursor: Add error handling for shm_pool_create() + +commit 8a023688c07fe2d377c4bc9631ce2fe7a9afee60 +Author: Kristian Høgsberg +Date: Mon Jul 2 14:34:48 2012 -0400 + + protocol: Add a couple of missing allow-null annotations + + wl_data_device.set_selection() allows NULL to withdraw the previously set + selection and wl_surface.attach() allows a NULL buffer to hide the surface. + +commit 11db60fe729539315c96745c50ae3160dc16001c +Author: Christopher James Halse Rogers +Date: Mon Jul 2 20:03:31 2012 +1000 + + protocol: Explicitly mark requests which allow null arguments + + Signed-off-by: Christopher James Halse Rogers + +commit 161c690b558fff9d0f407311ae4e1fbe389775f7 +Author: Christopher James Halse Rogers +Date: Mon Jul 2 20:03:30 2012 +1000 + + protocol: Add explicit nullable types + + Most of the time it does not make sense to pass a NULL object, string, or array + to a protocol request. This commit adds an explicit “allow-null” attribute + to mark the request arguments where NULL makes sense. + + Passing a NULL object, string, or array to a protocol request which is not + marked as allow-null is now an error. An implementation will never receive + a NULL value for these arguments from a client. + + Signed-off-by: Christopher James Halse Rogers + +commit d2bcffc470cf37dbdeb4d1ed46819360c16d92eb +Author: Dylan Noblesmith +Date: Fri Jun 15 22:56:37 2012 +0000 + + tests: test that path names longer than 108 bytes are rejected + + These would either overflow the struct sockaddr_un, or + be truncated and leave a non-null-terminated string. + +commit b486e3aba5c7618b7f6311e82b5fdb2c93f2beab +Author: Dylan Noblesmith +Date: Fri Jun 15 22:44:28 2012 +0000 + + tests: fix make check for out-of-tree builds + + It was failing with missing include files. + + While here, destroy the ugly "../src/..." include + paths used in the tests that was just hacking around + this problem in the Makefile: + + sed -i s/..\\/src\\/// tests/*.c + +commit c394b759586e2c20b249d6c48e2435388114d6da +Author: Dylan Noblesmith +Date: Fri Jun 15 22:06:58 2012 +0000 + + tests: sort list of tests + +commit af5f8cc2004ae6a56447614ac9d61ac75115ea7d +Author: Dylan Noblesmith +Date: Fri Jun 15 21:39:50 2012 +0000 + + wayland-client: reject socket paths longer than 108 bytes + + Attempting to write anything longer into the embedded char + array would create a non-null-terminated string, and all + later reads would run off the end into invalid memory. + + This is a hard limitation of AF_LOCAL/AF_UNIX sockets. + +commit 00c25a05656b0bbc3da56383ca2aa9be7f6ebdbf +Author: Dylan Noblesmith +Date: Fri Jun 15 21:32:19 2012 +0000 + + wayland-server: reject socket paths longer than 108 bytes + + Attempting to write anything longer into the embedded char + array would create a non-null-terminated string, and all + later reads would run off the end into invalid memory. + + This is a hard limitation of AF_LOCAL/AF_UNIX sockets. + +commit 4522467268492e64b690d93cf57749c099ce101e +Author: Dylan Noblesmith +Date: Sat Jun 16 22:51:35 2012 +0000 + + wayland-server: add more logging of errors + +commit 30ff420ca9707fbbde7e70e789a8698058b4cb4b +Author: Dylan Noblesmith +Date: Sat Jun 30 19:50:09 2012 +0000 + + wayland-server: fix socket ownership race condition + + Always unlink() the lock file before closing the file + descriptor for it. Otherwise, there is a race like this: + + Process A closes fd, releasing the lock + Process B opens the same file, taking the lock + Process A unlinks the lock file + Process C opens the same file, which now no longer exists, + and takes the lock on the newly created lock file + + Process B and C both 'own' the same display socket. + + unlink()ing while holding the lock is effectively a better + way to release the lock atomically. + +commit 94752574592a59c74340816063ad12a18433a75d +Author: Dylan Noblesmith +Date: Sat Jun 16 22:47:42 2012 +0000 + + wayland-server: fix fd leak on error path + + And restructure get_socket_lock() so it's clearer that it's + allocating a new file descriptor. + + Uncovered by an upcoming test. + +commit cadd9992921c92c4cf4c72ee40ff5ab4d44066cd +Author: Dylan Noblesmith +Date: Fri Jun 15 22:01:06 2012 +0000 + + drop use of strerror() + + It isn't thread-safe. Use the %m conversion specifier instead, + like the rest of the code already does. + +commit bb6e48b1b023e7d422fb5d67eef6505f7bdf2d05 +Author: Dylan Noblesmith +Date: Fri Jun 15 21:09:00 2012 +0000 + + wayland-server: reduce use of magic numbers + + Make it clear what the significance of '5' and '113' actually is. + Also drop an unneeded function argument. + commit 9de9e39f87adfce1ea9755e394928756254c0ba2 Author: Kristian Høgsberg Date: Thu Jun 28 22:01:58 2012 -0400 diff -Nru wayland-0.94.90+git20120630.9de9e39f/config.h.in wayland-0.94.90+git20120712.52e6dc71/config.h.in --- wayland-0.94.90+git20120630.9de9e39f/config.h.in 2012-06-30 07:34:07.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/config.h.in 2012-07-12 17:06:09.000000000 +0000 @@ -15,6 +15,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the `mkostemp' function. */ +#undef HAVE_MKOSTEMP + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff -Nru wayland-0.94.90+git20120630.9de9e39f/configure wayland-0.94.90+git20120712.52e6dc71/configure --- wayland-0.94.90+git20120630.9de9e39f/configure 2012-06-30 07:34:07.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/configure 2012-07-12 17:06:09.000000000 +0000 @@ -11603,12 +11603,13 @@ fi -for ac_func in accept4 +for ac_func in accept4 mkostemp do : - ac_fn_c_check_func "$LINENO" "accept4" "ac_cv_func_accept4" -if test "x$ac_cv_func_accept4" = xyes; then : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_ACCEPT4 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi diff -Nru wayland-0.94.90+git20120630.9de9e39f/configure.ac wayland-0.94.90+git20120712.52e6dc71/configure.ac --- wayland-0.94.90+git20120630.9de9e39f/configure.ac 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/configure.ac 2012-07-12 17:05:54.000000000 +0000 @@ -39,7 +39,7 @@ fi AC_SUBST(GCC_CFLAGS) -AC_CHECK_FUNCS([accept4]) +AC_CHECK_FUNCS([accept4 mkostemp]) AC_ARG_ENABLE([scanner], [AC_HELP_STRING([--disable-scanner], diff -Nru wayland-0.94.90+git20120630.9de9e39f/cursor/Makefile.am wayland-0.94.90+git20120712.52e6dc71/cursor/Makefile.am --- wayland-0.94.90+git20120630.9de9e39f/cursor/Makefile.am 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/cursor/Makefile.am 2012-07-12 17:05:54.000000000 +0000 @@ -4,6 +4,8 @@ libwayland_cursor_la_SOURCES = \ wayland-cursor.c \ + os-compatibility.c \ + os-compatibility.h \ xcursor.c \ xcursor.h libwayland_cursor_la_LIBADD = $(top_builddir)/src/libwayland-client.la diff -Nru wayland-0.94.90+git20120630.9de9e39f/cursor/Makefile.in wayland-0.94.90+git20120712.52e6dc71/cursor/Makefile.in --- wayland-0.94.90+git20120630.9de9e39f/cursor/Makefile.in 2012-06-30 07:34:08.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/cursor/Makefile.in 2012-07-12 17:06:10.000000000 +0000 @@ -101,7 +101,8 @@ LTLIBRARIES = $(lib_LTLIBRARIES) libwayland_cursor_la_DEPENDENCIES = \ $(top_builddir)/src/libwayland-client.la -am_libwayland_cursor_la_OBJECTS = wayland-cursor.lo xcursor.lo +am_libwayland_cursor_la_OBJECTS = wayland-cursor.lo \ + os-compatibility.lo xcursor.lo libwayland_cursor_la_OBJECTS = $(am_libwayland_cursor_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -276,6 +277,8 @@ include_HEADERS = wayland-cursor.h libwayland_cursor_la_SOURCES = \ wayland-cursor.c \ + os-compatibility.c \ + os-compatibility.h \ xcursor.c \ xcursor.h @@ -367,6 +370,7 @@ distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os-compatibility.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wayland-cursor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcursor.Plo@am__quote@ diff -Nru wayland-0.94.90+git20120630.9de9e39f/cursor/os-compatibility.c wayland-0.94.90+git20120712.52e6dc71/cursor/os-compatibility.c --- wayland-0.94.90+git20120630.9de9e39f/cursor/os-compatibility.c 1970-01-01 00:00:00.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/cursor/os-compatibility.c 2012-07-12 17:05:54.000000000 +0000 @@ -0,0 +1,128 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "os-compatibility.h" + +#ifndef HAVE_MKOSTEMP +static int +set_cloexec_or_close(int fd) +{ + long flags; + + if (fd == -1) + return -1; + + flags = fcntl(fd, F_GETFD); + if (flags == -1) + goto err; + + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) + goto err; + + return fd; + +err: + close(fd); + return -1; +} +#endif + +static int +create_tmpfile_cloexec(char *tmpname) +{ + int fd; + +#ifdef HAVE_MKOSTEMP + fd = mkostemp(tmpname, O_CLOEXEC); + if (fd >= 0) + unlink(tmpname); +#else + fd = mkstemp(tmpname); + if (fd >= 0) { + fd = set_cloexec_or_close(fd); + unlink(tmpname); + } +#endif + + return fd; +} + +/* + * Create a new, unique, anonymous file of the given size, and + * return the file descriptor for it. The file descriptor is set + * CLOEXEC. The file is immediately suitable for mmap()'ing + * the given size at offset zero. + * + * The file should not have a permanent backing store like a disk, + * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. + * + * The file name is deleted from the file system. + * + * The file is suitable for buffer sharing between processes by + * transmitting the file descriptor over Unix sockets using the + * SCM_RIGHTS methods. + */ +int +os_create_anonymous_file(off_t size) +{ + static const char template[] = "/weston-shared-XXXXXX"; + const char *path; + char *name; + int fd; + + path = getenv("XDG_RUNTIME_DIR"); + if (!path) { + errno = ENOENT; + return -1; + } + + name = malloc(strlen(path) + sizeof(template)); + if (!name) + return -1; + + strcpy(name, path); + strcat(name, template); + + fd = create_tmpfile_cloexec(name); + + free(name); + + if (fd < 0) + return -1; + + if (ftruncate(fd, size) < 0) { + close(fd); + return -1; + } + + return fd; +} diff -Nru wayland-0.94.90+git20120630.9de9e39f/cursor/os-compatibility.h wayland-0.94.90+git20120712.52e6dc71/cursor/os-compatibility.h --- wayland-0.94.90+git20120630.9de9e39f/cursor/os-compatibility.h 1970-01-01 00:00:00.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/cursor/os-compatibility.h 2012-07-12 17:05:54.000000000 +0000 @@ -0,0 +1,31 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef OS_COMPATIBILITY_H +#define OS_COMPATIBILITY_H + +#include + +int +os_create_anonymous_file(off_t size); + +#endif /* OS_COMPATIBILITY_H */ diff -Nru wayland-0.94.90+git20120630.9de9e39f/cursor/wayland-cursor.c wayland-0.94.90+git20120712.52e6dc71/cursor/wayland-cursor.c --- wayland-0.94.90+git20120630.9de9e39f/cursor/wayland-cursor.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/cursor/wayland-cursor.c 2012-07-12 17:05:54.000000000 +0000 @@ -29,6 +29,8 @@ #include #include +#include "os-compatibility.h" + struct shm_pool { struct wl_shm_pool *pool; int fd; @@ -41,35 +43,32 @@ shm_pool_create(struct wl_shm *shm, int size) { struct shm_pool *pool; - char filename[] = "/tmp/wayland-shm-XXXXXX"; pool = malloc(sizeof *pool); if (!pool) return NULL; - pool->fd = mkstemp(filename); + pool->fd = os_create_anonymous_file(size); if (pool->fd < 0) - return NULL; - - if (ftruncate(pool->fd, size) < 0) { - close(pool->fd); - return NULL; - } + goto err_free; pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, pool->fd, 0); - unlink(filename); - if (pool->data == MAP_FAILED) { - close(pool->fd); - return NULL; - } + if (pool->data == MAP_FAILED) + goto err_close; pool->pool = wl_shm_create_pool(shm, pool->fd, size); pool->size = size; pool->used = 0; return pool; + +err_close: + close(pool->fd); +err_free: + free(pool); + return NULL; } static int @@ -109,6 +108,7 @@ { munmap(pool->data, pool->size); wl_shm_pool_destroy(pool->pool); + close(pool->fd); free(pool); } @@ -282,6 +282,11 @@ theme->pool = shm_pool_create(shm, size * size * 4); + if (!theme->pool) { + free(theme->name); + free(theme); + return NULL; + } xcursor_load_theme(name, size, load_callback, theme); diff -Nru wayland-0.94.90+git20120630.9de9e39f/debian/changelog wayland-0.94.90+git20120712.52e6dc71/debian/changelog --- wayland-0.94.90+git20120630.9de9e39f/debian/changelog 2012-07-12 17:14:39.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/debian/changelog 2012-07-12 17:14:40.000000000 +0000 @@ -1,11 +1,11 @@ -wayland (0.94.90+git20120630.9de9e39f-0ubuntu0ricotz~precise) precise; urgency=low +wayland (0.94.90+git20120712.52e6dc71-0ubuntu0ricotz~precise) precise; urgency=medium - * Checkout from git 20120630 (master branch) up to commit - 9de9e39f87adfce1ea9755e394928756254c0ba2 + * Checkout from git 20120712 (master branch) up to commit + 52e6dc71becf4ee7f473f8af79fd71f95b6889c0 * Only added debian/ tree from origin/ubuntu * hook: Ignore test failures. - -- Rico Tzschichholz Sat, 30 Jun 2012 09:34:09 +0200 + -- Rico Tzschichholz Thu, 12 Jul 2012 19:06:11 +0200 wayland (0.85.0-1ubuntu2) precise; urgency=low diff -Nru wayland-0.94.90+git20120630.9de9e39f/doc/Wayland/en_US/Protocol.xml wayland-0.94.90+git20120712.52e6dc71/doc/Wayland/en_US/Protocol.xml --- wayland-0.94.90+git20120630.9de9e39f/doc/Wayland/en_US/Protocol.xml 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/doc/Wayland/en_US/Protocol.xml 2012-07-12 17:05:54.000000000 +0000 @@ -168,7 +168,7 @@ wl_display - provides global functionality like objecting binding and + provides global functionality like object binding and fatal error events @@ -442,7 +442,7 @@ - geometry needs position in compositor coordinate system\ + geometry needs position in compositor coordinate system diff -Nru wayland-0.94.90+git20120630.9de9e39f/.lastcommit wayland-0.94.90+git20120712.52e6dc71/.lastcommit --- wayland-0.94.90+git20120630.9de9e39f/.lastcommit 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/.lastcommit 2012-07-12 17:05:54.000000000 +0000 @@ -1 +1 @@ -commit 9de9e39f87adfce1ea9755e394928756254c0ba2 +commit 52e6dc71becf4ee7f473f8af79fd71f95b6889c0 diff -Nru wayland-0.94.90+git20120630.9de9e39f/protocol/wayland.xml wayland-0.94.90+git20120712.52e6dc71/protocol/wayland.xml --- wayland-0.94.90+git20120630.9de9e39f/protocol/wayland.xml 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/protocol/wayland.xml 2012-07-12 17:05:54.000000000 +0000 @@ -250,7 +250,7 @@ - + @@ -292,7 +292,7 @@ a target does not accept any of the offered types, type is NULL. - + @@ -335,14 +335,14 @@ hotspot, but subsequent surface.attach request can move the relative position. - + - + - + @@ -365,7 +365,7 @@ - + @@ -390,7 +390,7 @@ data_offer is valid until a new data_offer or NULL is received or until the client loses keyboard focus. - + @@ -502,7 +502,7 @@ - + @@ -565,7 +565,7 @@ to, except the panel area. This is the main difference between a maximized shell surface and a fullscreen shell surface. - + @@ -635,7 +635,7 @@ corner, relative to the old buffers upper left corner. - + @@ -697,7 +697,7 @@ region is the entire surface. - + @@ -797,7 +797,7 @@ - + @@ -1008,9 +1008,9 @@ + summary="width in millimeters of the output"/> + summary="height in millimeters of the output"/> nullable = 1; + signature++; + } else + details->nullable = 0; + + details->type = *signature; + return signature + 1; +} + +static int +arg_count_for_signature(const char *signature) +{ + int count = 0; + while (*signature) { + if (*signature != '?') + count++; + signature++; + } + return count; +} + struct wl_closure * wl_closure_vmarshal(struct wl_object *sender, uint32_t opcode, va_list ap, @@ -415,6 +445,8 @@ int dup_fd; struct wl_array **arrayp, *array; const char **sp, *s; + const char *signature = message->signature; + struct argument_details arg; char *extra; int i, count, fd, extra_size, *fd_ptr; @@ -424,7 +456,7 @@ return NULL; extra_size = wl_message_size_extra(message); - count = strlen(message->signature) + 2; + count = arg_count_for_signature(signature) + 2; extra = (char *) closure->buffer; start = &closure->buffer[DIV_ROUNDUP(extra_size, sizeof *p)]; end = &closure->buffer[256]; @@ -434,7 +466,9 @@ closure->types[1] = &ffi_type_pointer; for (i = 2; i < count; i++) { - switch (message->signature[i - 2]) { + signature = get_next_argument(signature, &arg); + + switch (arg.type) { case 'f': closure->types[i] = &ffi_type_sint32; closure->args[i] = p; @@ -463,6 +497,10 @@ extra += sizeof *sp; s = va_arg(ap, const char *); + + if (!arg.nullable && s == NULL) + goto err_null; + length = s ? strlen(s) + 1: 0; if (p + DIV_ROUNDUP(length, sizeof *p) + 1 > end) goto err; @@ -483,6 +521,10 @@ extra += sizeof *objectp; object = va_arg(ap, struct wl_object *); + + if (!arg.nullable && object == NULL) + goto err_null; + *objectp = object; if (end - p < 1) goto err; @@ -508,6 +550,10 @@ extra += sizeof **arrayp; array = va_arg(ap, struct wl_array *); + + if (!arg.nullable && array == NULL) + goto err_null; + if (array == NULL || array->size == 0) { if (end - p < 1) goto err; @@ -542,7 +588,7 @@ break; default: fprintf(stderr, "unhandled format code: '%c'\n", - message->signature[i - 2]); + arg.type); assert(0); break; } @@ -567,6 +613,15 @@ errno = ENOMEM; return NULL; + +err_null: + free(closure); + wl_log("error marshalling arguments for %s:%i.%s (signature %s): " + "null value passed for arg %i\n", + sender->interface->name, sender->id, message->name, + message->signature, i); + errno = EINVAL; + return NULL; } struct wl_closure * @@ -579,11 +634,13 @@ int *fd; char *extra, **s; unsigned int i, count, extra_space; + const char *signature = message->signature; + struct argument_details arg; struct wl_object **object; struct wl_array **array; struct wl_closure *closure; - count = strlen(message->signature) + 2; + count = arg_count_for_signature(signature) + 2; if (count > ARRAY_LENGTH(closure->types)) { printf("too many args (%d)\n", count); errno = EINVAL; @@ -606,6 +663,8 @@ end = (uint32_t *) ((char *) p + size); extra = (char *) end; for (i = 2; i < count; i++) { + signature = get_next_argument(signature, &arg); + if (p + 1 > end) { printf("message too short, " "object (%d), message %s(%s)\n", @@ -614,7 +673,7 @@ goto err; } - switch (message->signature[i - 2]) { + switch (arg.type) { case 'u': closure->types[i] = &ffi_type_uint32; closure->args[i] = p++; @@ -784,11 +843,14 @@ { const struct wl_message *message = closure->message; uint32_t i, count; + struct argument_details arg; + const char *signature = message->signature; int *fd; - count = strlen(message->signature) + 2; + count = arg_count_for_signature(signature) + 2; for (i = 2; i < count; i++) { - if (message->signature[i - 2] != 'h') + signature = get_next_argument(signature, &arg); + if (arg.type != 'h') continue; fd = closure->args[i]; @@ -834,6 +896,8 @@ union wl_value *value; int32_t si; int i; + struct argument_details arg; + const char *signature = closure->message->signature; struct timespec tp; unsigned int time; @@ -847,11 +911,12 @@ closure->message->name); for (i = 2; i < closure->count; i++) { + signature = get_next_argument(signature, &arg); if (i > 2) fprintf(stderr, ", "); value = closure->args[i]; - switch (closure->message->signature[i - 2]) { + switch (arg.type) { case 'u': fprintf(stderr, "%u", value->uint32); break; diff -Nru wayland-0.94.90+git20120630.9de9e39f/src/scanner.c wayland-0.94.90+git20120712.52e6dc71/src/scanner.c --- wayland-0.94.90+git20120630.9de9e39f/src/scanner.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/src/scanner.c 2012-07-12 17:05:54.000000000 +0000 @@ -93,6 +93,7 @@ struct arg { char *name; enum arg_type type; + int nullable; char *interface_name; struct wl_list link; char *summary; @@ -220,6 +221,20 @@ exit(EXIT_FAILURE); } +static int +is_nullable_type(struct arg *arg) +{ + switch (arg->type) { + /* Strings, objects, and arrays are possibly nullable */ + case STRING: + case OBJECT: + case ARRAY: + return 1; + default: + return 0; + } +} + static void start_element(void *data, const char *element_name, const char **atts) { @@ -231,6 +246,7 @@ struct entry *entry; struct description *description; const char *name, *type, *interface_name, *value, *summary, *since; + const char *allow_null; char *end; int i, version; @@ -242,6 +258,7 @@ summary = NULL; description = NULL; since = NULL; + allow_null = NULL; for (i = 0; atts[i]; i += 2) { if (strcmp(atts[i], "name") == 0) name = atts[i + 1]; @@ -257,6 +274,8 @@ summary = atts[i + 1]; if (strcmp(atts[i], "since") == 0) since = atts[i + 1]; + if (strcmp(atts[i], "allow-null") == 0) + allow_null = atts[i + 1]; } ctx->character_data_length = 0; @@ -364,6 +383,16 @@ break; } + if (allow_null == NULL || strcmp(allow_null, "false") == 0) + arg->nullable = 0; + else if (strcmp(allow_null, "true") == 0) + arg->nullable = 1; + else + fail(ctx, "invalid value for allow-null attribute"); + + if (allow_null != NULL && !is_nullable_type(arg)) + fail(ctx, "allow-null is only valid for objects, strings, and arrays"); + arg->summary = NULL; if (summary) arg->summary = strdup(summary); @@ -433,7 +462,7 @@ char *text = strndup(ctx->character_data, ctx->character_data_length); if (text) - ctx->description->text = strdup(text); + ctx->description->text = text; ctx->description = NULL; } else if (strcmp(name, "request") == 0 || strcmp(name, "event") == 0) { @@ -839,11 +868,12 @@ "\n" "#include \n" "#include \n" - "#include \"wayland-util.h\"\n\n" + "#include \"%s\"\n\n" "struct wl_client;\n" "struct wl_resource;\n\n", protocol->uppercase_name, s, - protocol->uppercase_name, s); + protocol->uppercase_name, s, + server ? "wayland-util.h" : "wayland-client.h"); wl_list_for_each(i, &protocol->interface_list, link) printf("struct %s;\n", i->name); @@ -969,6 +999,9 @@ wl_list_for_each(m, message_list, link) { printf("\t{ \"%s\", \"", m->name); wl_list_for_each(a, &m->arg_list, link) { + if (is_nullable_type(a) && a->nullable) + printf("?"); + switch (a->type) { default: case INT: @@ -1086,7 +1119,7 @@ buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE); len = fread(buf, 1, XML_BUFFER_SIZE, stdin); if (len < 0) { - fprintf(stderr, "fread: %s\n", strerror(errno)); + fprintf(stderr, "fread: %m\n"); exit(EXIT_FAILURE); } XML_ParseBuffer(ctx.parser, len, len == 0); diff -Nru wayland-0.94.90+git20120630.9de9e39f/src/wayland-client.c wayland-0.94.90+git20120712.52e6dc71/src/wayland-client.c --- wayland-0.94.90+git20120630.9de9e39f/src/wayland-client.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/src/wayland-client.c 2012-07-12 17:05:54.000000000 +0000 @@ -305,7 +305,7 @@ struct sockaddr_un addr; socklen_t size; const char *runtime_dir; - size_t name_size; + int name_size; runtime_dir = getenv("XDG_RUNTIME_DIR"); if (!runtime_dir) { @@ -333,6 +333,18 @@ snprintf(addr.sun_path, sizeof addr.sun_path, "%s/%s", runtime_dir, name) + 1; + assert(name_size > 0); + if (name_size > (int)sizeof addr.sun_path) { + fprintf(stderr, + "error: socket path \"%s/%s\" plus null terminator" + " exceeds 108 bytes\n", runtime_dir, name); + close(display->fd); + /* to prevent programs reporting + * "failed to add socket: Success" */ + errno = ENAMETOOLONG; + return -1; + }; + size = offsetof (struct sockaddr_un, sun_path) + name_size; if (connect(display->fd, (struct sockaddr *) &addr, size) < 0) { diff -Nru wayland-0.94.90+git20120630.9de9e39f/src/wayland-server.c wayland-0.94.90+git20120712.52e6dc71/src/wayland-server.c --- wayland-0.94.90+git20120630.9de9e39f/src/wayland-server.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/src/wayland-server.c 2012-07-12 17:05:54.000000000 +0000 @@ -46,11 +46,21 @@ #include "wayland-server-protocol.h" #include "wayland-os.h" +/* This is the size of the char array in struct sock_addr_un. + No Wayland socket can be created with a path longer than this, + including the null terminator. */ +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX 108 +#endif + +#define LOCK_SUFFIX ".lock" +#define LOCK_SUFFIXLEN 5 + struct wl_socket { int fd; int fd_lock; struct sockaddr_un addr; - char lock_addr[113]; + char lock_addr[UNIX_PATH_MAX + LOCK_SUFFIXLEN]; struct wl_list link; struct wl_event_source *source; }; @@ -488,6 +498,15 @@ } static void +lose_touch_focus(struct wl_listener *listener, void *data) +{ + struct wl_touch *touch = + container_of(listener, struct wl_touch, focus_listener); + + touch->focus_resource = NULL; +} + +static void default_grab_focus(struct wl_pointer_grab *grab, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { @@ -656,6 +675,7 @@ { memset(touch, 0, sizeof *touch); wl_list_init(&touch->resource_list); + touch->focus_listener.notify = lose_touch_focus; } WL_EXPORT void @@ -730,7 +750,7 @@ { if (keyboard && (seat->keyboard || keyboard->seat)) return; /* XXX: error? */ - if (!keyboard && seat->keyboard) + if (!keyboard && !seat->keyboard) return; seat->keyboard = keyboard; @@ -749,7 +769,7 @@ return; seat->touch = touch; - if (!touch) + if (touch) touch->seat = seat; seat_send_updated_caps(seat); @@ -991,10 +1011,10 @@ wl_list_for_each_safe(s, next, &display->socket_list, link) { wl_event_source_remove(s->source); - close(s->fd); unlink(s->addr.sun_path); - close(s->fd_lock); + close(s->fd); unlink(s->lock_addr); + close(s->fd_lock); free(s); } wl_event_loop_destroy(display->loop); @@ -1092,7 +1112,7 @@ client_fd = wl_os_accept_cloexec(fd, (struct sockaddr *) &name, &length); if (client_fd < 0) - wl_log("failed to accept, errno: %d\n", errno); + wl_log("failed to accept: %m\n"); else wl_client_create(display, client_fd); @@ -1100,27 +1120,27 @@ } static int -get_socket_lock(struct wl_socket *socket, socklen_t name_size) +get_socket_lock(struct wl_socket *socket) { struct stat socket_stat; - int lock_size = name_size + 5; + int fd_lock; - snprintf(socket->lock_addr, lock_size, - "%s.lock", socket->addr.sun_path); + snprintf(socket->lock_addr, sizeof socket->lock_addr, + "%s%s", socket->addr.sun_path, LOCK_SUFFIX); - socket->fd_lock = open(socket->lock_addr, O_CREAT | O_CLOEXEC, - (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)); + fd_lock = open(socket->lock_addr, O_CREAT | O_CLOEXEC, + (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)); - if (socket->fd_lock < 0) { + if (fd_lock < 0) { wl_log("unable to open lockfile %s check permissions\n", socket->lock_addr); return -1; } - if (flock(socket->fd_lock, LOCK_EX | LOCK_NB) < 0) { + if (flock(fd_lock, LOCK_EX | LOCK_NB) < 0) { wl_log("unable to lock lockfile %s, maybe another compositor is running\n", socket->lock_addr); - close(socket->fd_lock); + close(fd_lock); return -1; } @@ -1128,7 +1148,7 @@ if (errno != ENOENT) { wl_log("did not manage to stat file %s\n", socket->addr.sun_path); - close(socket->fd_lock); + close(fd_lock); return -1; } } else if (socket_stat.st_mode & S_IWUSR || @@ -1136,14 +1156,15 @@ unlink(socket->addr.sun_path); } - return 0; + return fd_lock; } WL_EXPORT int wl_display_add_socket(struct wl_display *display, const char *name) { struct wl_socket *s; - socklen_t size, name_size; + socklen_t size; + int name_size; const char *runtime_dir; runtime_dir = getenv("XDG_RUNTIME_DIR"); @@ -1175,9 +1196,23 @@ s->addr.sun_family = AF_LOCAL; name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path, "%s/%s", runtime_dir, name) + 1; + + assert(name_size > 0); + if (name_size > (int)sizeof s->addr.sun_path) { + wl_log("error: socket path \"%s/%s\" plus null terminator" + " exceeds 108 bytes\n", runtime_dir, name); + close(s->fd); + free(s); + /* to prevent programs reporting + * "failed to add socket: Success" */ + errno = ENAMETOOLONG; + return -1; + }; + wl_log("using socket %s\n", s->addr.sun_path); - if (get_socket_lock(s,name_size) < 0) { + s->fd_lock = get_socket_lock(s); + if (s->fd_lock < 0) { close(s->fd); free(s); return -1; @@ -1185,14 +1220,20 @@ size = offsetof (struct sockaddr_un, sun_path) + name_size; if (bind(s->fd, (struct sockaddr *) &s->addr, size) < 0) { + wl_log("bind() failed with error: %m\n"); close(s->fd); + unlink(s->lock_addr); + close(s->fd_lock); free(s); return -1; } if (listen(s->fd, 1) < 0) { - close(s->fd); + wl_log("listen() failed with error: %m\n"); unlink(s->addr.sun_path); + close(s->fd); + unlink(s->lock_addr); + close(s->fd_lock); free(s); return -1; } @@ -1201,8 +1242,10 @@ WL_EVENT_READABLE, socket_data, display); if (s->source == NULL) { - close(s->fd); unlink(s->addr.sun_path); + close(s->fd); + unlink(s->lock_addr); + close(s->fd_lock); free(s); return -1; } diff -Nru wayland-0.94.90+git20120630.9de9e39f/src/wayland-shm.c wayland-0.94.90+git20120712.52e6dc71/src/wayland-shm.c --- wayland-0.94.90+git20120630.9de9e39f/src/wayland-shm.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/src/wayland-shm.c 2012-07-12 17:05:54.000000000 +0000 @@ -188,29 +188,27 @@ pool = malloc(sizeof *pool); if (pool == NULL) { wl_resource_post_no_memory(resource); - close(fd); - return; + goto err_close; } if (size <= 0) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE, "invalid size (%d)", size); - close(fd); - return; + goto err_free; } pool->refcount = 1; pool->size = size; pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - close(fd); if (pool->data == MAP_FAILED) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD, "failed mmap fd %d", fd); - return; + goto err_free; } + close(fd); pool->resource.object.id = id; pool->resource.object.interface = &wl_shm_pool_interface; @@ -222,6 +220,13 @@ pool->resource.destroy = destroy_pool; wl_client_add_resource(client, &pool->resource); + + return; + +err_close: + close(fd); +err_free: + free(pool); } static const struct wl_shm_interface shm_interface = { diff -Nru wayland-0.94.90+git20120630.9de9e39f/src/wayland-util.h wayland-0.94.90+git20120712.52e6dc71/src/wayland-util.h --- wayland-0.94.90+git20120630.9de9e39f/src/wayland-util.h 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/src/wayland-util.h 2012-07-12 17:05:54.000000000 +0000 @@ -77,7 +77,7 @@ * empty in O(1), use wl_list_empty(). * * Let's call the list reference "struct wl_list foo_list", the item type as - * "item_t", and the item member as "struct wl_list link". The following code + * "item_t", and the item member as "struct wl_list link". * * The following code will initialize a list: * @@ -92,7 +92,7 @@ * wl_list_init(&foo_list); * wl_list_insert(&foo_list, &item1.link); Pushes item1 at the head * wl_list_insert(&foo_list, &item2.link); Pushes item2 at the head - * wl_list_insert(&item2.link, &item3.link);Pushes item3 after item2 + * wl_list_insert(&item2.link, &item3.link); Pushes item3 after item2 * * The list now looks like [item2, item3, item1] * diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/array-test.c wayland-0.94.90+git20120712.52e6dc71/tests/array-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/array-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/array-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -22,7 +22,7 @@ #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" TEST(array_init) diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/client-test.c wayland-0.94.90+git20120712.52e6dc71/tests/client-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/client-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/client-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -31,7 +31,7 @@ #include #include -#include "../src/wayland-server.h" +#include "wayland-server.h" #include "test-runner.h" struct client_destroy_listener { diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/connection-test.c wayland-0.94.90+git20120712.52e6dc71/tests/connection-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/connection-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/connection-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -32,7 +32,7 @@ #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" static const char message[] = "Hello, world"; @@ -233,9 +233,6 @@ marshal(&data, "o", 12, &object); assert(data.buffer[2] == object.id); - marshal(&data, "o", 12, NULL); - assert(data.buffer[2] == 0); - marshal(&data, "n", 12, &object); assert(data.buffer[2] == object.id); @@ -252,6 +249,68 @@ } static void +expected_fail_marshal(int expected_error, const char *format, ...) +{ + struct wl_closure *closure; + static const uint32_t opcode = 4444; + static const struct wl_interface test_interface = { + .name = "test_object" + }; + static struct wl_object sender = { 0 }; + struct wl_message message = { "test", format, NULL }; + + sender.interface = &test_interface; + sender.id = 1234; + va_list ap; + + va_start(ap, format); + closure = wl_closure_vmarshal(&sender, opcode, ap, &message); + va_end(ap); + + assert(closure == NULL); + assert(errno == expected_error); +} + +TEST(connection_marshal_nullables) +{ + struct marshal_data data; + struct wl_object object; + struct wl_array array; + const char text[] = "curry"; + + setup_marshal_data(&data); + + expected_fail_marshal(EINVAL, "o", NULL); + expected_fail_marshal(EINVAL, "s", NULL); + expected_fail_marshal(EINVAL, "a", NULL); + + marshal(&data, "?o", 12, NULL); + assert(data.buffer[2] == 0); + + marshal(&data, "?a", 12, NULL); + assert(data.buffer[2] == 0); + + marshal(&data, "?s", 12, NULL); + assert(data.buffer[2] == 0); + + object.id = 55293; + marshal(&data, "?o", 12, &object); + assert(data.buffer[2] == object.id); + + array.data = (void *) text; + array.size = sizeof text; + marshal(&data, "?a", 20, &array); + assert(data.buffer[2] == array.size); + assert(memcmp(&data.buffer[3], text, array.size) == 0); + + marshal(&data, "?s", 20, text); + assert(data.buffer[2] == sizeof text); + assert(strcmp((char *) &data.buffer[3], text) == 0); + + release_marshal_data(&data); +} + +static void validate_demarshal_u(struct marshal_data *data, struct wl_object *object, uint32_t u) { @@ -269,7 +328,10 @@ validate_demarshal_s(struct marshal_data *data, struct wl_object *object, const char *s) { - assert(strcmp(data->value.s, s) == 0); + if (data->value.s != NULL) + assert(strcmp(data->value.s, s) == 0); + else + assert(s == NULL); } static void @@ -343,12 +405,25 @@ memcpy(&msg[3], data.value.s, msg[2]); demarshal(&data, "s", msg, (void *) validate_demarshal_s); + data.value.s = "superdude"; + msg[0] = 400200; + msg[1] = 24; + msg[2] = 10; + memcpy(&msg[3], data.value.s, msg[2]); + demarshal(&data, "?s", msg, (void *) validate_demarshal_s); + data.value.i = wl_fixed_from_double(-90000.2390); msg[0] = 400200; msg[1] = 12; msg[2] = data.value.i; demarshal(&data, "f", msg, (void *) validate_demarshal_f); + data.value.s = NULL; + msg[0] = 400200; + msg[1] = 12; + msg[2] = 0; + demarshal(&data, "?s", msg, (void *) validate_demarshal_s); + release_marshal_data(&data); } @@ -408,6 +483,10 @@ marshal_demarshal(&data, (void *) validate_demarshal_s, 28, "s", data.value.s); + data.value.s = "cookie robots"; + marshal_demarshal(&data, (void *) validate_demarshal_s, + 28, "?s", data.value.s); + data.value.h = mkstemp(f); assert(data.value.h >= 0); marshal_demarshal(&data, (void *) validate_demarshal_h, diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/event-loop-test.c wayland-0.94.90+git20120712.52e6dc71/tests/event-loop-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/event-loop-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/event-loop-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -24,7 +24,7 @@ #include #include #include -#include "../src/wayland-server.h" +#include "wayland-server.h" #include "test-runner.h" static int diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/fixed-benchmark.c wayland-0.94.90+git20120712.52e6dc71/tests/fixed-benchmark.c --- wayland-0.94.90+git20120630.9de9e39f/tests/fixed-benchmark.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/fixed-benchmark.c 2012-07-12 17:05:54.000000000 +0000 @@ -25,7 +25,7 @@ #include #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" volatile double global_d; diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/fixed-test.c wayland-0.94.90+git20120712.52e6dc71/tests/fixed-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/fixed-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/fixed-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -23,7 +23,7 @@ #include #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" TEST(fixed_double_conversions) diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/list-test.c wayland-0.94.90+git20120712.52e6dc71/tests/list-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/list-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/list-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -23,7 +23,7 @@ #include #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" TEST(list_init) diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/Makefile.am wayland-0.94.90+git20120712.52e6dc71/tests/Makefile.am --- wayland-0.94.90+git20120630.9de9e39f/tests/Makefile.am 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/Makefile.am 2012-07-12 17:05:54.000000000 +0000 @@ -1,13 +1,14 @@ TESTS = \ - sanity-test \ array-test \ - map-test \ - list-test \ + client-test \ connection-test \ event-loop-test \ - client-test \ + fixed-test \ + list-test \ + map-test \ os-wrappers-test \ - fixed-test + sanity-test \ + socket-test check_PROGRAMS = \ $(TESTS) \ @@ -18,14 +19,15 @@ test_runner_src = test-runner.c test-runner.h test-helpers.c -sanity_test_SOURCES = sanity-test.c $(test_runner_src) -map_test_SOURCES = map-test.c $(test_runner_src) array_test_SOURCES = array-test.c $(test_runner_src) -list_test_SOURCES = list-test.c $(test_runner_src) +client_test_SOURCES = client-test.c $(test_runner_src) connection_test_SOURCES = connection-test.c $(test_runner_src) event_loop_test_SOURCES = event-loop-test.c $(test_runner_src) -client_test_SOURCES = client-test.c $(test_runner_src) fixed_test_SOURCES = fixed-test.c $(test_runner_src) +list_test_SOURCES = list-test.c $(test_runner_src) +map_test_SOURCES = map-test.c $(test_runner_src) +sanity_test_SOURCES = sanity-test.c $(test_runner_src) +socket_test_SOURCES = socket-test.c $(test_runner_src) fixed_benchmark_SOURCES = fixed-benchmark.c @@ -34,8 +36,10 @@ ../src/wayland-os.c \ $(test_runner_src) -AM_CFLAGS = $(GCC_CFLAGS) $(FFI_CFLAGS) -I../src +AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src +AM_CFLAGS = $(GCC_CFLAGS) $(FFI_CFLAGS) LDADD = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la \ -lrt -ldl $(FFI_LIBS) diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/Makefile.in wayland-0.94.90+git20120712.52e6dc71/tests/Makefile.in --- wayland-0.94.90+git20120630.9de9e39f/tests/Makefile.in 2012-06-30 07:34:08.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/Makefile.in 2012-07-12 17:06:10.000000000 +0000 @@ -51,10 +51,11 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -TESTS = sanity-test$(EXEEXT) array-test$(EXEEXT) map-test$(EXEEXT) \ - list-test$(EXEEXT) connection-test$(EXEEXT) \ - event-loop-test$(EXEEXT) client-test$(EXEEXT) \ - os-wrappers-test$(EXEEXT) fixed-test$(EXEEXT) +TESTS = array-test$(EXEEXT) client-test$(EXEEXT) \ + connection-test$(EXEEXT) event-loop-test$(EXEEXT) \ + fixed-test$(EXEEXT) list-test$(EXEEXT) map-test$(EXEEXT) \ + os-wrappers-test$(EXEEXT) sanity-test$(EXEEXT) \ + socket-test$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) exec-fd-leak-checker$(EXEEXT) noinst_PROGRAMS = fixed-benchmark$(EXEEXT) subdir = tests @@ -70,10 +71,11 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__EXEEXT_1 = sanity-test$(EXEEXT) array-test$(EXEEXT) \ - map-test$(EXEEXT) list-test$(EXEEXT) connection-test$(EXEEXT) \ - event-loop-test$(EXEEXT) client-test$(EXEEXT) \ - os-wrappers-test$(EXEEXT) fixed-test$(EXEEXT) +am__EXEEXT_1 = array-test$(EXEEXT) client-test$(EXEEXT) \ + connection-test$(EXEEXT) event-loop-test$(EXEEXT) \ + fixed-test$(EXEEXT) list-test$(EXEEXT) map-test$(EXEEXT) \ + os-wrappers-test$(EXEEXT) sanity-test$(EXEEXT) \ + socket-test$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am__objects_1 = test-runner.$(OBJEXT) test-helpers.$(OBJEXT) am_array_test_OBJECTS = array-test.$(OBJEXT) $(am__objects_1) @@ -81,6 +83,7 @@ array_test_LDADD = $(LDADD) am__DEPENDENCIES_1 = array_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -89,18 +92,21 @@ client_test_OBJECTS = $(am_client_test_OBJECTS) client_test_LDADD = $(LDADD) client_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_connection_test_OBJECTS = connection-test.$(OBJEXT) \ $(am__objects_1) connection_test_OBJECTS = $(am_connection_test_OBJECTS) connection_test_LDADD = $(LDADD) connection_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_event_loop_test_OBJECTS = event-loop-test.$(OBJEXT) \ $(am__objects_1) event_loop_test_OBJECTS = $(am_event_loop_test_OBJECTS) event_loop_test_LDADD = $(LDADD) event_loop_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_exec_fd_leak_checker_OBJECTS = exec-fd-leak-checker.$(OBJEXT) \ test-helpers.$(OBJEXT) @@ -110,21 +116,25 @@ fixed_benchmark_OBJECTS = $(am_fixed_benchmark_OBJECTS) fixed_benchmark_LDADD = $(LDADD) fixed_benchmark_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_fixed_test_OBJECTS = fixed-test.$(OBJEXT) $(am__objects_1) fixed_test_OBJECTS = $(am_fixed_test_OBJECTS) fixed_test_LDADD = $(LDADD) fixed_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_list_test_OBJECTS = list-test.$(OBJEXT) $(am__objects_1) list_test_OBJECTS = $(am_list_test_OBJECTS) list_test_LDADD = $(LDADD) list_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_map_test_OBJECTS = map-test.$(OBJEXT) $(am__objects_1) map_test_OBJECTS = $(am_map_test_OBJECTS) map_test_LDADD = $(LDADD) map_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_os_wrappers_test_OBJECTS = os-wrappers-test.$(OBJEXT) \ wayland-os.$(OBJEXT) $(am__objects_1) @@ -132,11 +142,19 @@ os_wrappers_test_LDADD = $(LDADD) os_wrappers_test_DEPENDENCIES = \ $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) am_sanity_test_OBJECTS = sanity-test.$(OBJEXT) $(am__objects_1) sanity_test_OBJECTS = $(am_sanity_test_OBJECTS) sanity_test_LDADD = $(LDADD) sanity_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ + $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) +am_socket_test_OBJECTS = socket-test.$(OBJEXT) $(am__objects_1) +socket_test_OBJECTS = $(am_socket_test_OBJECTS) +socket_test_LDADD = $(LDADD) +socket_test_DEPENDENCIES = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -168,12 +186,14 @@ $(connection_test_SOURCES) $(event_loop_test_SOURCES) \ $(exec_fd_leak_checker_SOURCES) $(fixed_benchmark_SOURCES) \ $(fixed_test_SOURCES) $(list_test_SOURCES) $(map_test_SOURCES) \ - $(os_wrappers_test_SOURCES) $(sanity_test_SOURCES) + $(os_wrappers_test_SOURCES) $(sanity_test_SOURCES) \ + $(socket_test_SOURCES) DIST_SOURCES = $(array_test_SOURCES) $(client_test_SOURCES) \ $(connection_test_SOURCES) $(event_loop_test_SOURCES) \ $(exec_fd_leak_checker_SOURCES) $(fixed_benchmark_SOURCES) \ $(fixed_test_SOURCES) $(list_test_SOURCES) $(map_test_SOURCES) \ - $(os_wrappers_test_SOURCES) $(sanity_test_SOURCES) + $(os_wrappers_test_SOURCES) $(sanity_test_SOURCES) \ + $(socket_test_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -313,22 +333,25 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ test_runner_src = test-runner.c test-runner.h test-helpers.c -sanity_test_SOURCES = sanity-test.c $(test_runner_src) -map_test_SOURCES = map-test.c $(test_runner_src) array_test_SOURCES = array-test.c $(test_runner_src) -list_test_SOURCES = list-test.c $(test_runner_src) +client_test_SOURCES = client-test.c $(test_runner_src) connection_test_SOURCES = connection-test.c $(test_runner_src) event_loop_test_SOURCES = event-loop-test.c $(test_runner_src) -client_test_SOURCES = client-test.c $(test_runner_src) fixed_test_SOURCES = fixed-test.c $(test_runner_src) +list_test_SOURCES = list-test.c $(test_runner_src) +map_test_SOURCES = map-test.c $(test_runner_src) +sanity_test_SOURCES = sanity-test.c $(test_runner_src) +socket_test_SOURCES = socket-test.c $(test_runner_src) fixed_benchmark_SOURCES = fixed-benchmark.c os_wrappers_test_SOURCES = \ os-wrappers-test.c \ ../src/wayland-os.c \ $(test_runner_src) -AM_CFLAGS = $(GCC_CFLAGS) $(FFI_CFLAGS) -I../src +AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src +AM_CFLAGS = $(GCC_CFLAGS) $(FFI_CFLAGS) LDADD = $(top_builddir)/src/libwayland-util.la \ + $(top_builddir)/src/libwayland-client.la \ $(top_builddir)/src/libwayland-server.la \ -lrt -ldl $(FFI_LIBS) @@ -423,6 +446,9 @@ sanity-test$(EXEEXT): $(sanity_test_OBJECTS) $(sanity_test_DEPENDENCIES) $(EXTRA_sanity_test_DEPENDENCIES) @rm -f sanity-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sanity_test_OBJECTS) $(sanity_test_LDADD) $(LIBS) +socket-test$(EXEEXT): $(socket_test_OBJECTS) $(socket_test_DEPENDENCIES) $(EXTRA_socket_test_DEPENDENCIES) + @rm -f socket-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(socket_test_OBJECTS) $(socket_test_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -441,6 +467,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os-wrappers-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanity-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-helpers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-runner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wayland-os.Po@am__quote@ diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/map-test.c wayland-0.94.90+git20120712.52e6dc71/tests/map-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/map-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/map-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -23,7 +23,7 @@ #include #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" TEST(map_insert_new) diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/os-wrappers-test.c wayland-0.94.90+git20120712.52e6dc71/tests/os-wrappers-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/os-wrappers-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/os-wrappers-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -36,9 +36,9 @@ #include #include -#include "../src/wayland-private.h" +#include "wayland-private.h" #include "test-runner.h" -#include "../src/wayland-os.h" +#include "wayland-os.h" static int fall_back; diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/sanity-test.c wayland-0.94.90+git20120712.52e6dc71/tests/sanity-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/sanity-test.c 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/sanity-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -27,7 +27,7 @@ #include #include "test-runner.h" -#include "../src/wayland-util.h" +#include "wayland-util.h" TEST(empty) { diff -Nru wayland-0.94.90+git20120630.9de9e39f/tests/socket-test.c wayland-0.94.90+git20120712.52e6dc71/tests/socket-test.c --- wayland-0.94.90+git20120630.9de9e39f/tests/socket-test.c 1970-01-01 00:00:00.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/tests/socket-test.c 2012-07-12 17:05:54.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include "wayland-client.h" +#include "wayland-server.h" +#include "test-runner.h" + +/* Paths longer than what the .sun_path array can contain must be rejected. + This is a hard limitation of assigning a name to AF_UNIX/AF_LOCAL sockets. + See `man 7 unix`. */ + +static const struct sockaddr_un example_sockaddr_un; + +#define TOO_LONG (1 + sizeof example_sockaddr_un.sun_path) + +TEST(socket_path_overflow_client_connect) +{ + char path[TOO_LONG]; + struct wl_display *d; + int ret; + + /* Ensure the connection doesn't fail due to lack of + XDG_RUNTIME_DIR. Don't use setenv(), as that allocates + memory and creates a spurious memory leak failure. */ + ret = putenv("XDG_RUNTIME_DIR=."); + assert(ret == 0); + + memset(path, 'a', sizeof path); + path[sizeof path - 1] = '\0'; + + d = wl_display_connect(path); + assert(d == NULL); + assert(errno == ENAMETOOLONG); +} + +TEST(socket_path_overflow_server_create) +{ + char path[TOO_LONG]; + struct wl_display *d; + int ret; + + /* Ensure the connection doesn't fail due to lack of + XDG_RUNTIME_DIR. Don't use setenv(), as that allocates + memory and creates a spurious memory leak failure. */ + ret = putenv("XDG_RUNTIME_DIR=."); + assert(ret == 0); + + memset(path, 'a', sizeof path); + path[sizeof path - 1] = '\0'; + + d = wl_display_create(); + assert(d != NULL); + + ret = wl_display_add_socket(d, path); + assert(ret < 0); + assert(errno == ENAMETOOLONG); + + wl_display_destroy(d); +} diff -Nru wayland-0.94.90+git20120630.9de9e39f/TODO wayland-0.94.90+git20120712.52e6dc71/TODO --- wayland-0.94.90+git20120630.9de9e39f/TODO 2012-06-30 07:33:53.000000000 +0000 +++ wayland-0.94.90+git20120712.52e6dc71/TODO 2012-07-12 17:05:54.000000000 +0000 @@ -19,7 +19,7 @@ bigger atomic change. To be researched a bit. - Maybe try to make remote wayland actually happen, to see if there - is something in the protocol/architecute that makes it harder than + is something in the protocol/architecture that makes it harder than it should be. - Add timestamp to touch_cancel, add touch id to touch_cancel (?)