summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-02 14:22:32 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-11-02 14:22:32 -0500
commit66498b0110dc8966a1d98a450249de26559fd495 (patch)
tree3dd000ef6273912c0db7864f2a37264cebb66b68 /src/libudev
parent27756785c2303998f3cd2e24885085d1feff348d (diff)
libudev: do not accept invalid log levels
Invalid log levels lead to a assert failure later on. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-util.c10
-rw-r--r--src/libudev/libudev.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index 00dc6e157e..e30bdc2434 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -162,9 +162,13 @@ int util_log_priority(const char *priority)
char *endptr;
int prio;
- prio = strtol(priority, &endptr, 10);
- if (endptr[0] == '\0' || isspace(endptr[0]))
- return prio;
+ prio = strtoul(priority, &endptr, 10);
+ if (endptr[0] == '\0' || isspace(endptr[0])) {
+ if (prio >= 0 && prio <= 7)
+ return prio;
+ else
+ return -ERANGE;
+ }
return log_level_from_string(priority);
}
diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index beb9a65481..5d3ad50411 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -192,7 +192,13 @@ _public_ struct udev *udev_new(void)
}
if (streq(key, "udev_log")) {
- udev_set_log_priority(udev, util_log_priority(val));
+ int prio;
+
+ prio = util_log_priority(val);
+ if (prio < 0)
+ udev_err(udev, "/etc/udev/udev.conf:%u: invalid logging level '%s', ignoring.\n", line_nr, val);
+ else
+ udev_set_log_priority(udev, prio);
continue;
}
}