summaryrefslogtreecommitdiff
path: root/src/libudev/libudev-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-01 12:06:41 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-01 14:39:47 -0400
commitee7122c0ec6aa11f02e9e8d94254b353f12d2c14 (patch)
treef3beaae878a894016b8c5af3a424fb41daad788d /src/libudev/libudev-util.c
parentfe756ed9ec2c0fa33c30b1d9a33d745dc1593aed (diff)
libudev: do not accept invalid log levels
Invalid log levels lead to a assert failure later on. https://bugs.freedesktop.org/show_bug.cgi?id=85657
Diffstat (limited to 'src/libudev/libudev-util.c')
-rw-r--r--src/libudev/libudev-util.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index f3fdf3b5aa..0bc10f3470 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -159,9 +159,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);
}