svn commit: r278634 - head/lib/libc/gen

Andrey Chernov ache at freebsd.org
Fri Feb 13 07:47:08 UTC 2015


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