diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-11-02 14:22:32 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-11-02 14:22:32 -0500 |
commit | 66498b0110dc8966a1d98a450249de26559fd495 (patch) | |
tree | 3dd000ef6273912c0db7864f2a37264cebb66b68 /src/libudev/libudev-util.c | |
parent | 27756785c2303998f3cd2e24885085d1feff348d (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/libudev-util.c')
-rw-r--r-- | src/libudev/libudev-util.c | 10 |
1 files changed, 7 insertions, 3 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); } |