Subject: Re: bin/31377: ksh: cannot set limit indicated by ulimit -H
To: None <tech-userlevel@netbsd.org>
From: Simon Gerraty <sjg@juniper.net>
List: tech-userlevel
Date: 09/24/2005 20:34:42
On Sat, 24 Sep 2005 20:24:57 -0700 (PDT), Simon Gerraty writes:
>
>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