summaryrefslogtreecommitdiff
path: root/udev_rules.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-03-28 12:37:54 +0200
committerGreg KH <gregkh@suse.de>2005-04-26 23:55:00 -0700
commitbb1a77d34cd004b44b30a79d7521957c3881e497 (patch)
treeb08e3df127f942f8a7254faeb573131cc7bd5e27 /udev_rules.c
parentdb949b02489f521e32a052280f913e06b7c87e37 (diff)
[PATCH] check for strlen()==0 before accessing strlen()-1
Diffstat (limited to 'udev_rules.c')
-rw-r--r--udev_rules.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/udev_rules.c b/udev_rules.c
index b7905477de..c07abb9be0 100644
--- a/udev_rules.c
+++ b/udev_rules.c
@@ -594,15 +594,16 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule,
for (i = 0; i < rule->sysfs_pair_count; i++) {
struct key_pair *pair;
char value[VALUE_SIZE];
+ size_t len;
pair = &rule->sysfs_pair[i];
if (find_sysfs_attribute(class_dev, parent_device, pair->name, value, sizeof(value)) != 0)
goto try_parent;
/* strip trailing whitespace of value, if not asked to match for it */
- if (!isspace(pair->value[strlen(pair->value)-1])) {
- size_t len = strlen(value);
-
+ len = strlen(pair->value);
+ if (len && !isspace(pair->value[len-1])) {
+ len = strlen(value);
while (len > 0 && isspace(value[len-1]))
value[--len] = '\0';
dbg("removed %i trailing whitespace chars from '%s'", strlen(value)-len, value);