From d05676f2322c70e1dadbe863eab03c968494a2d1 Mon Sep 17 00:00:00 2001 From: illiliti Date: Sat, 25 Jul 2020 16:44:17 +0300 Subject: [PATCH] drop O_NOFOLLOW --- udev_device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/udev_device.c b/udev_device.c index fb6387b..df8a609 100644 --- a/udev_device.c +++ b/udev_device.c @@ -245,11 +245,11 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const snprintf(path, sizeof(path), "%s/%s", udev_device_get_syspath(udev_device), sysattr); - if (stat(path, &st) != 0 || S_ISDIR(st.st_mode)) { + if (lstat(path, &st) != 0 || !S_ISREG(st.st_mode)) { return NULL; } - fd = open(path, O_RDONLY | O_NOFOLLOW); + fd = open(path, O_RDONLY); if (fd == -1) { return NULL; @@ -278,11 +278,11 @@ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *s snprintf(path, sizeof(path), "%s/%s", udev_device_get_syspath(udev_device), sysattr); - if (stat(path, &st) != 0 || S_ISDIR(st.st_mode)) { + if (lstat(path, &st) != 0 || !S_ISREG(st.st_mode)) { return -1; } - fd = open(path, O_WRONLY | O_NOFOLLOW); + fd = open(path, O_WRONLY); if (fd == -1) { return -1;