diff options
-rw-r--r-- | src/libudev/libudev-util.c | 10 | ||||
-rw-r--r-- | src/libudev/libudev.c | 8 |
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; } } |