X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_sysfs.c;h=e8909f94f1f6166249fbcad8f571d7c0baa2b790;hp=34ae9ac14fd400758d5d3a618dc527d19a9bbd54;hb=6e509e539b15ae882afd8ce3fafe1fbd33008509;hpb=fd80719273b9d58f88fc5d576cdb67a1fd92e2bb diff --git a/udev_sysfs.c b/udev_sysfs.c index 34ae9ac14..e8909f94f 100644 --- a/udev_sysfs.c +++ b/udev_sysfs.c @@ -355,6 +355,8 @@ char *sysfs_attr_get_value(const char *devpath, const char *attr_name) dbg("open '%s'/'%s'", devpath, attr_name); sysfs_len = strlcpy(path_full, sysfs_path, sizeof(path_full)); + if(sysfs_len >= sizeof(path_full)) + sysfs_len = sizeof(path_full) - 1; path = &path_full[sysfs_len]; strlcat(path_full, devpath, sizeof(path_full)); strlcat(path_full, "/", sizeof(path_full)); @@ -413,7 +415,7 @@ char *sysfs_attr_get_value(const char *devpath, const char *attr_name) /* read attribute value */ fd = open(path_full, O_RDONLY); if (fd < 0) { - dbg("attribute '%s' does not exist", path_full); + dbg("attribute '%s' can not be opened", path_full); goto out; } size = read(fd, value, sizeof(value));