[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bash 2.05 ulimit mishandles large ulimits on 64-bit hosts
From: |
Paul Eggert |
Subject: |
bash 2.05 ulimit mishandles large ulimits on 64-bit hosts |
Date: |
Fri, 27 Apr 2001 17:45:20 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: cc -xarch=v9
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7'
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I. -I.. -I../include -I../lib
-I/tmp/prefix/include -g
uname output: SunOS sic.twinsun.com 5.7 Generic_106541-15 sun4u sparc
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.7
Bash Version: 2.05
Patch Level: 0
Release Status: release
Description:
The 'ulimit' command attempts to check for overflow when computing
large values, but the check is done incorrectly, and some overflows
are not caught on hosts with 32-bit int and 64-bit RLIMTYPE, e.g.
64-bit Solaris (sparc).
Repeat-By:
$ ulimit -v
unlimited
$ ulimit -v 18014398509481983
$ ulimit -v
18014398509481983
$ ulimit -v 18014398509481984
bash: ulimit: limit out of range: 0
(The error message should say "18014398509481984", not "0".)
$ ulimit -v
18014398509481983
$ ulimit -v 18014398509481985
(This should have reported an error.)
$ ulimit -v
1
(The ulimit was set to '1'; it should have not been changed.)
Fix:
This patch also clears up a related bit of code 'filesize' in the same
module; this simplifies the code a tiny bit.
2001-04-27 Paul Eggert <eggert@twinsun.com>
* builtins/ulimit.def (ulimit_internal):
Fix check for overflow when computing RLIMTYPE values.
(filesize): No need to use 512L; 512 will do in all cases.
===================================================================
RCS file: builtins/ulimit.def,v
retrieving revision 2.5
retrieving revision 2.5.0.1
diff -pu -r2.5 -r2.5.0.1
--- builtins/ulimit.def 2000/12/18 15:37:45 2.5
+++ builtins/ulimit.def 2001/04/28 00:29:53 2.5.0.1
@@ -347,7 +347,7 @@ ulimit_internal (cmd, cmdarg, mode, mult
int mode, multiple;
{
int opt, limind, setting;
- long block_factor;
+ int block_factor;
RLIMTYPE current_limit, real_limit, limit;
setting = cmdarg != 0;
@@ -381,9 +381,9 @@ ulimit_internal (cmd, cmdarg, mode, mult
block_factor = (limit == RLIM_INFINITY) ? 1 : limits[limind].block_factor;
real_limit = limit * block_factor;
- if (real_limit < 0 || (real_limit == 0 && limit != 0))
+ if (real_limit / block_factor != limit)
{
- builtin_error ("limit out of range: %d", limit);
+ builtin_error ("limit out of range: %s", cmdarg);
return (EXECUTION_FAILURE);
}
@@ -560,7 +560,7 @@ filesize(valuep)
# if 0
*valuep = (RLIMTYPE) result;
# else
- *valuep = (RLIMTYPE) result * 512L;
+ *valuep = (RLIMTYPE) result * 512;
# endif
return 0;
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bash 2.05 ulimit mishandles large ulimits on 64-bit hosts,
Paul Eggert <=