diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2014-03-11 16:58:18 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2014-03-11 17:25:39 -0400 |
commit | 81025e37ea5f2aeacbe11b7cec628ef46c75a68b (patch) | |
tree | a419d8153240b1a1f6860e940cd9522bd2866e8f | |
parent | 1bb9f1e33303f9d98b112cae2d9972ab35618bda (diff) | |
download | mutter-81025e37ea5f2aeacbe11b7cec628ef46c75a68b.tar.gz |
weston-launch: Stat the path before opening it
-rw-r--r-- | src/wayland/weston-launch.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/wayland/weston-launch.c b/src/wayland/weston-launch.c index 773eea4bd..36394c848 100644 --- a/src/wayland/weston-launch.c +++ b/src/wayland/weston-launch.c @@ -331,20 +331,18 @@ handle_open(struct weston_launch *wl, struct msghdr *msg, ssize_t len) goto err0; } - fd = open(message->path, message->flags); - if (fd < 0) { - fprintf(stderr, "Error opening device %s: %m\n", + if (major(s.st_rdev) != INPUT_MAJOR) { + fprintf(stderr, "Device %s is not an input device\n", message->path); - reply.ret = -errno; + reply.ret = -EPERM; goto err0; } - if (major(s.st_rdev) != INPUT_MAJOR) { - close(fd); - fd = -1; - fprintf(stderr, "Device %s is not an input device\n", + fd = open(message->path, message->flags); + if (fd < 0) { + fprintf(stderr, "Error opening device %s: %m\n", message->path); - reply.ret = -EPERM; + reply.ret = -errno; goto err0; } |