diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-11-07 14:54:21 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-11-12 23:03:40 +0100 |
commit | 7bf0149e9b46d614c3431e39ca59805aebf71bc4 (patch) | |
tree | 2e5b9e3477047753ff094f05ec65d812873f0128 /src/basic | |
parent | audit-util: modernize use_audit() a bit (diff) | |
download | systemd-7bf0149e9b46d614c3431e39ca59805aebf71bc4.tar.xz systemd-7bf0149e9b46d614c3431e39ca59805aebf71bc4.zip |
process-util: more gracefully handle oom adjust parsing/setting
Who knows what kind of mount shenanigans people employ, let's gracefully
handle parse failures of proc files, like we alway do otherwsie.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/process-util.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index ee0edfaf94..9c159b4605 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1815,6 +1815,9 @@ int namespace_fork( int set_oom_score_adjust(int value) { char t[DECIMAL_STR_MAX(int)]; + if (!oom_score_adjust_is_valid(value)) + return -EINVAL; + xsprintf(t, "%i", value); return write_string_file("/proc/self/oom_score_adj", t, @@ -1831,11 +1834,16 @@ int get_oom_score_adjust(int *ret) { delete_trailing_chars(t, WHITESPACE); - assert_se(safe_atoi(t, &a) >= 0); - assert_se(oom_score_adjust_is_valid(a)); + r = safe_atoi(t, &a); + if (r < 0) + return r; + + if (!oom_score_adjust_is_valid(a)) + return -ENODATA; if (ret) *ret = a; + return 0; } |