chiark / gitweb /
libudev: do not accept invalid log levels
[elogind.git] / src / libudev / libudev-util.c
index f3fdf3b5aa7843fd91789ab732ec370002f1150f..0bc10f3470ac39783ad46d0f8d7fb5dd988f3835 100644 (file)
@@ -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);
 }