svn commit: r278634 - head/lib/libc/gen
Andrey Chernov
ache at freebsd.org
Fri Feb 13 08:00:00 UTC 2015
We even don't need to check arg excepting for < 0, because what is
needed is rlimt_t and not arg. So this version will be better:
rlimt_t targ;
if (arg < 0) {
errno = EINVAL;
return (-1);
}
targ = arg;
if (targ > RLIM_INFINITY / 512)
targ = RLIM_INFINITY / 512;
limit.rlim_max = limit.rlim_cur = targ * 512
On 13.02.2015 10:46, Andrey Chernov wrote:
> On 13.02.2015 10:18, Bruce Evans wrote:
>> if (arg > RLIM_INFINITY)
>> err(...);
>
> Checking for RLIM_INFINITY is wrong here, since it is ulong long max,
> considering
> arg = va_arg(ap, long);
> and ulimit(3) stating that arg is always plain long.
>
> Proper check will be
>
> if (arg < 0) {
> errno = EINVAL;
> return (-1);
> }
> if (arg > LONG_MAX / 512)
> arg = LONG_MAX / 512;
>
> That all. In pure theoretical case RLIM_INFINITY is less than LONG_MAX,
> it is job of underlying setrlimit(2) to return error.
>
--
http://ache.vniz.net/
More information about the svn-src-all
mailing list