Trim whitespace from input string before parsing in `OomScoreAdhFileOps::write_at` method

This commit is contained in:
Xinyi Yu 2026-01-28 09:51:26 +00:00 committed by Tate, Hongliang Tian
parent a599a2c563
commit 01cf00a4c6
1 changed files with 1 additions and 0 deletions

View File

@ -43,6 +43,7 @@ impl FileOps for OomScoreAdjFileOps {
let val = cstr
.to_str()
.ok()
.map(|str| str.trim())
.and_then(|str| str.parse::<i32>().ok())
.ok_or_else(|| {
Error::with_message(Errno::EINVAL, "the value is not a valid integer")