chiark / gitweb /
cap-list: check range of numeric value
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Nov 2017 13:06:34 +0000 (22:06 +0900)
committerSven Eden <yamakuzure@gmx.net>
Tue, 28 Nov 2017 13:06:34 +0000 (22:06 +0900)
src/basic/cap-list.c

index 2e9b2d9a550c5be5a90c3230552a6003d504e1a3..2b1779668079c7355e4bffad878ae100146a2098 100644 (file)
@@ -53,8 +53,12 @@ int capability_from_name(const char *name) {
 
         /* Try to parse numeric capability */
         r = safe_atoi(name, &i);
-        if (r >= 0 && i >= 0)
-                return i;
+        if (r >= 0) {
+                if (i >= 0 && i < (int) ELEMENTSOF(capability_names))
+                        return i;
+                else
+                        return -EINVAL;
+        }
 
         /* Try to parse string capability */
         sc = lookup_capability(name, strlen(name));