diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2015-11-27 08:54:42 +0000 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2015-11-27 11:26:37 +0000 |
commit | 0316f2aeebde7569d24a93ab788ac4bc1657b11b (patch) | |
tree | 0b9a3d09993a8d2e234e7c46afbb71f9e0284c91 /src/core | |
parent | e0d8c8015a089e9a8e971be5ebe2139bb714c10a (diff) |
core: fix rlimit parsing
* refuse limits if soft > hard
* print an actual value instead of (null)
see https://github.com/systemd/systemd/pull/1994#issuecomment-159999123
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/load-fragment.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 8847578bd7..3c124495b6 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1173,6 +1173,7 @@ static int parse_rlimit_range( struct rlimit **rl, int (*rlim_parser)(const char *, rlim_t *)) { + const char *whole_value = value; rlim_t soft, hard; _cleanup_free_ char *sword = NULL, *hword = NULL; int nwords, r; @@ -1188,9 +1189,11 @@ static int parse_rlimit_range( if (r == 0 && nwords == 2) r = rlim_parser(hword, &hard); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", value); + log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", whole_value); return 0; } + if (nwords == 2 && soft > hard) + return log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid resource value ("RLIM_FMT" > "RLIM_FMT"), ignoring: %s", soft, hard, whole_value); if (!*rl) { *rl = new(struct rlimit, 1); |