From e9c8fdf4faa84ccab92a78caa2fc899d3e42bcbe Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Nov 2017 22:06:34 +0900 Subject: cap-list: check range of numeric value --- src/basic/cap-list.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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)); -- cgit v1.2.3