https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6d049c54c3314da31d9ffac133a6a2f2dfecaac2

commit 6d049c54c3314da31d9ffac133a6a2f2dfecaac2
Author:     Corinna Vinschen <[email protected]>
AuthorDate: Sun Jan 25 23:31:34 2026 +0100
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Fri Feb 13 20:23:36 2026 +0100

    Cygwin: setrlimit: fix comments in terms of input checking
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/resource.cc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index 9dfe36b13e36..1e9e91810c8d 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -296,24 +296,25 @@ setrlimit (int resource, const struct rlimit *rlp)
 {
   struct rlimit oldlimits;
 
-  /* Check if the request is to actually change the resource settings.
-     If it does not result in a change, take no action and do not fail. */
   if (getrlimit (resource, &oldlimits) < 0)
     return -1;
 
   __try
     {
+      /* Check if the request is to actually change the resource settings.
+        If it does not result in a change, take no action and do not fail. */
       if (oldlimits.rlim_cur == rlp->rlim_cur &&
          oldlimits.rlim_max == rlp->rlim_max)
-       /* No change in resource requirements, succeed immediately */
        return 0;
 
+      /* soft limit > hard limit ? EINVAL */
       if (rlp->rlim_cur > rlp->rlim_max)
        {
          set_errno (EINVAL);
          __leave;
        }
 
+      /* hard limit > current hard limit ? EPERM if not admin */
       if (rlp->rlim_max > oldlimits.rlim_max
          && !check_token_membership (well_known_admins_sid))
        {

Reply via email to