1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

cap-list: check range of numeric value

This commit is contained in:
Yu Watanabe 2017-11-28 22:06:34 +09:00
parent 6b86b9e65d
commit db4bd5bd62

View File

@ -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));