From: duna.oh Date: Mon, 5 Sep 2022 02:17:00 +0000 (+0900) Subject: libinput: do not call close() when fd is negative X-Git-Tag: accepted/tizen/unified/20220908.013417~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de5b3cc065c2b6551085136255aeaa29689f4cf5;p=platform%2Fcore%2Fuifw%2Flibds.git libinput: do not call close() when fd is negative fix potential security issue Change-Id: Ie6ee22ced3c913902124daed181056bfdcaa7cd7 --- diff --git a/src/backend/libinput/backend.c b/src/backend/libinput/backend.c index b7e1bc4..7a7ed02 100644 --- a/src/backend/libinput/backend.c +++ b/src/backend/libinput/backend.c @@ -80,8 +80,11 @@ libinput_open_restricted(const char *path, int flags, void *_backend) fd = open(path, flags | O_CLOEXEC); - if (fd < 0 || (fstat(fd, &s) == -1)) { + if (fd < 0) { ds_log(DS_ERR, "Could not open device"); + return -1; + } + if (fstat(fd, &s) == -1) { close(fd); return -1; } @@ -226,4 +229,4 @@ libinput_backend_handle_display_destroy(struct wl_listener *listener, uint32_t usec_to_msec(uint64_t usec) { return (uint32_t)(usec / 1000); -} \ No newline at end of file +}