-attr_found:
- c = strchr(tmpattr->value, '\n');
- if (c != NULL)
- c[0] = '\0';
-
- dbg("found attribute '%s'", tmpattr->path);
- return tmpattr;
-}
-
-static int compare_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, struct key_pair *pair)
-{
- struct sysfs_attribute *tmpattr;
- int i;
- int len;
-
- if ((pair == NULL) || (pair->name[0] == '\0') || (pair->value == '\0'))
- return -ENODEV;
-
- tmpattr = find_sysfs_attribute(class_dev, sysfs_device, pair->name);
- if (tmpattr == NULL)
- return -ENODEV;
-
- /* strip trailing whitespace of value, if not asked to match for it */
- if (! isspace(pair->value[strlen(pair->value)-1])) {
- i = len = strlen(tmpattr->value);
- while (i > 0 && isspace(tmpattr->value[i-1]))
- i--;
- if (i < len) {
- tmpattr->value[i] = '\0';
- dbg("remove %i trailing whitespace chars from '%s'",
- len - i, tmpattr->value);
- }
- }
-
- dbg("compare attribute '%s' value '%s' with '%s'",
- pair->name, tmpattr->value, pair->value);
- if (strcmp_pattern(pair->value, tmpattr->value) != 0)
- return -ENODEV;
+ if (!retval) {
+ remove_trailing_char(value, '\n');
+ dbg("result is '%s'", value);
+ replace_untrusted_chars(value);
+ } else
+ value[0] = '\0';