From a753fb6520e4e7b860e1bbd108bda1fba3c5c1b6 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Thu, 29 Jun 2023 20:11:41 +0200 Subject: [PATCH] prlimit: reject trailing junk in limits without ":" Before: $ prlimit --verbose --core=1x New CORE limit for pid 42: <1:1> After: $ prlimit --verbose --core=1x prlimit: failed to parse CORE limit Signed-off-by: Jakub Wilk --- sys-utils/prlimit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index e067c8cd76..a8f633d835 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -455,8 +455,10 @@ static int get_range(char *str, rlim_t *soft, rlim_t *hard, int *found) } *found |= PRLIMIT_SOFT | PRLIMIT_HARD; - } else /* */ + } else if (!*end) /* */ *found |= PRLIMIT_SOFT | PRLIMIT_HARD; + else + return -1; return 0; } -- 2.47.3