mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
ulimit: Fix multiplication overflow
This commit is contained in:
parent
8736d9b1e7
commit
eee44b7469
2 changed files with 19 additions and 1 deletions
|
@ -305,7 +305,16 @@ pub fn ulimit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
||||||
None => return STATUS_CMD_ERROR,
|
None => return STATUS_CMD_ERROR,
|
||||||
}
|
}
|
||||||
} else if let Ok(limit) = fish_wcstol(w.argv[w.wopt_index]) {
|
} 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 {
|
} else {
|
||||||
streams.err.append(wgettext_fmt!(
|
streams.err.append(wgettext_fmt!(
|
||||||
"%ls: Invalid limit '%ls'\n",
|
"%ls: Invalid limit '%ls'\n",
|
||||||
|
|
|
@ -5,3 +5,12 @@ ulimit --core-size
|
||||||
ulimit --core-size 0
|
ulimit --core-size 0
|
||||||
ulimit --core-size
|
ulimit --core-size
|
||||||
#CHECK: 0
|
#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 a new issue