cap-list: check range of numeric value
This commit is contained in:
@@ -54,8 +54,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));
|
||||
|
||||
Reference in New Issue
Block a user