summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2017-11-28 22:06:34 +0900
committerSven Eden <yamakuzure@gmx.net>2017-11-28 22:06:34 +0900
commite9c8fdf4faa84ccab92a78caa2fc899d3e42bcbe (patch)
tree39df3e0457dc77124a1238805160b8a6fc00022e /src
parent5660be16ab1f2a51ec2ee0190bca75914d6353bd (diff)
cap-list: check range of numeric value
Diffstat (limited to 'src')
-rw-r--r--src/basic/cap-list.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c
index 2e9b2d9a5..2b1779668 100644
--- a/src/basic/cap-list.c
+++ b/src/basic/cap-list.c
@@ -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));