mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-18 20:53:40 +08:00
ulimit: Fix multiplication overflow
This commit is contained in:
parent
8736d9b1e7
commit
eee44b7469
|
@ -305,7 +305,16 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
|||
None => return STATUS_CMD_ERROR,
|
||||
}
|
||||
} else if let Ok(limit) = fish_wcstol(w.argv[w.wopt_index]) {
|
||||
limit as rlim_t * get_multiplier(what)
|
||||
let Some(x) = get_multiplier(what).checked_mul(limit as rlim_t) else {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
"%ls: Invalid limit '%ls'\n",
|
||||
cmd,
|
||||
w.argv[w.wopt_index]
|
||||
));
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
return STATUS_INVALID_ARGS;
|
||||
};
|
||||
x
|
||||
} else {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
"%ls: Invalid limit '%ls'\n",
|
||||
|
|
|
@ -5,3 +5,12 @@ ulimit --core-size
|
|||
ulimit --core-size 0
|
||||
ulimit --core-size
|
||||
#CHECK: 0
|
||||
|
||||
ulimit 4352353252352352334
|
||||
#CHECKERR: ulimit: Invalid limit '4352353252352352334'
|
||||
#CHECKERR:
|
||||
#CHECKERR: checks/ulimit.fish (line {{\d+}}):
|
||||
#CHECKERR: ulimit 4352353252352352334
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: (Type 'help ulimit' for related documentation)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user