Subject: Re: bin/31377: ksh: cannot set limit indicated by ulimit -H
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Simon Gerraty <sjg@juniper.net>
List: netbsd-bugs
Date: 09/25/2005 03:25:02
The following reply was made to PR bin/31377; it has been noted by GNATS.

From: Simon Gerraty <sjg@juniper.net>
To: tech-userland@netbsd.org
Cc: gnats-bugs@netbsd.org, sjg@juniper.net
Subject: Re: bin/31377: ksh: cannot set limit indicated by ulimit -H 
Date: Sat, 24 Sep 2005 20:24:57 -0700 (PDT)

 Ok, the problem here is that the limit for -d happens to be
 2147483648, but because ksh munges that to/from kbyte units (factor of
 1024) and is using a signed value (rlim_t), when we try to set that
 limit (after multiplying by 1024 again) we get -2147483648 which is why
 it fails. 
 
 I'm not sure why rlim_t is signed, but the simple patch below avoids the
 above:
 
 Index: c_ulimit.c
 ===================================================================
 RCS file: /cvsroot/src/bin/ksh/c_ulimit.c,v
 retrieving revision 1.7
 diff -u -p -r1.7 c_ulimit.c
 --- c_ulimit.c	7 Jul 2004 19:20:09 -0000	1.7
 +++ c_ulimit.c	25 Sep 2005 03:13:29 -0000
 @@ -194,6 +194,8 @@ c_ulimit(wp)
  			    return 1;
  			}
  			val = rval * l->factor;
 +			if (val < 0)
 +			    val = -val;
  		}
  	}
  	if (all) {
 
 FWIW, the problem didn't show up in earlier NetBSD releases because the
 limit was lower (1/2 the limit in 3.99)
 
 --sjg