Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:GA
sysfsutils
sysfsutils-Fix-issue-with-sysfs-name-comparison...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sysfsutils-Fix-issue-with-sysfs-name-comparisons.patch of Package sysfsutils
From 270af678d42413069f3e6c8809984e9610a05c9c Mon Sep 17 00:00:00 2001 From: Lee Duncan <lduncan@suse.com> Date: Fri, 3 Jul 2020 11:14:20 -0700 Subject: [PATCH 2/3] Fix issue with sysfs name comparisons. It turns out that cdev_name_equal() is used by dlist_find_custom() to compare sysfs entry names to ones already seen. But it was comparing using the length of the shortest string as a maximum, so when it compared, for example, "eth1" and "eth10", it thought they were the same. So now just return failure if the strings aren't the same length, else go ahead and compare them. --- lib/sysfs_class.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c index 4fe0b82f2480..c696ff04b620 100644 --- a/lib/sysfs_class.c +++ b/lib/sysfs_class.c @@ -60,13 +60,30 @@ void sysfs_close_class(struct sysfs_class *cls) } } +/* + * pass this function to dlist_find_custom() + * so it can compare device names + * + * return 1 if pathnames are equal, else 0 + */ static int cdev_name_equal(void *a, void *b) { + size_t length_a, length_b; + char *str_a, *str_b; + if (!a || !b) return 0; - if (strncmp((char *)a, ((struct sysfs_class_device *)b)->name, - strlen((char *)a)) == 0) + str_a = (char *)a; + str_b = ((struct sysfs_class_device *)b)->name; + + length_a = strnlen(str_a, SYSFS_NAME_LEN+1); + length_b = strnlen(str_b, SYSFS_NAME_LEN+1); + + if (length_a != length_b) + return 0; + + if (strncmp(str_a, str_b, SYSFS_NAME_LEN+1) == 0) return 1; return 0; -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor