diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2021-11-30 12:48:34 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2021-11-30 12:55:14 +0100 |
commit | 670beaed0216aa59603501e8f14e1f04b138bc47 (patch) | |
tree | 7547471b5652c44525328d4a6f969cad08b0b0d4 | |
parent | d64cd470ae9b089d5e334efe7ed5ec4be68577d5 (diff) | |
download | newlib-670beaed0216aa59603501e8f14e1f04b138bc47.zip newlib-670beaed0216aa59603501e8f14e1f04b138bc47.tar.gz newlib-670beaed0216aa59603501e8f14e1f04b138bc47.tar.bz2 |
Cygwin: setrlimit: Add a permission check
If the incoming soft limit is less restrictive than the current
hard limit, bail out with EPERM. Given the previous sanity check,
this implies trying to raise the hard limit. While, theoretically,
this should be allowed for privileged processes, Windows has no
matching concept in terms of job limits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/resource.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 46d74b9..c4c79ca 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -261,6 +261,12 @@ setrlimit (int resource, const struct rlimit *rlp) __leave; } + if (rlp->rlim_cur > oldlimits.rlim_max) + { + set_errno (EPERM); + __leave; + } + switch (resource) { case RLIMIT_AS: |