From: Yu Watanabe Date: Tue, 28 Nov 2017 13:06:34 +0000 (+0900) Subject: cap-list: check range of numeric value X-Git-Tag: v236~100^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db4bd5bd625320071fa27e1accba53ab0d0ff948;p=thirdparty%2Fsystemd.git cap-list: check range of numeric value --- diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c index 52b2ce800fd..c4557666efd 100644 --- a/src/basic/cap-list.c +++ b/src/basic/cap-list.c @@ -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));