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

2015-02-13 Thread Andrey Chernov
On 13.02.2015 17:29, Bruce Evans wrote: >> if (arg < 0) { >>errno = EINVAL; >>return (-1); >> } > > > This is reasonable, but not encouraged by the API or compatible with > what setrlimit() does with negative args. (setrlimit() still uses > my hack from 1994, of converting negative args

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

2015-02-13 Thread Pedro Giffuni
On 02/13/15 11:46, Bruce Evans wrote: On Fri, 13 Feb 2015, Pedro Giffuni wrote: On 02/13/15 09:29, Bruce Evans wrote: On Fri, 13 Feb 2015, Andrey Chernov wrote: 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:

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

2015-02-13 Thread Bruce Evans
On Fri, 13 Feb 2015, Pedro Giffuni wrote: On 02/13/15 09:29, Bruce Evans wrote: On Fri, 13 Feb 2015, Andrey Chernov wrote: 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

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

2015-02-13 Thread Pedro Giffuni
On 02/13/15 09:29, Bruce Evans wrote: On Fri, 13 Feb 2015, Andrey Chernov wrote: 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); } This is reas

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

2015-02-13 Thread Bruce Evans
On Sat, 14 Feb 2015, Bruce Evans wrote: ... However, I don't like using rlim_t for the scaled value that is not an rlimit. An incomplete fix with handling of negative values restored is something like: intmax_t targ; targ = arg; if (targ > RLIM_INFINITY / 512)

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

2015-02-13 Thread Bruce Evans
On Fri, 13 Feb 2015, Andrey Chernov wrote: 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); } This is reasonable, but not encouraged by the API or

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

2015-02-13 Thread Bruce Evans
On Fri, 13 Feb 2015, 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, No, it is correct. rlim_t is neither unsigned not specificially ulong long. It is int64_t

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

2015-02-13 Thread Andrey Chernov
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.

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

2015-02-12 Thread Andrey Chernov
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

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

2015-02-12 Thread Bruce Evans
On Thu, 12 Feb 2015, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 22:34 , Pedro Giffuni wrote: On 02/12/15 17:27, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: ... Log: ulimit(3): Fix broken check. ... Did this compile? Yes! Any log message to share? Now I do ag

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

2015-02-12 Thread Pedro Giffuni
On 02/12/15 18:54, Garrett Cooper wrote: On Feb 12, 2015, at 15:14, Pedro Giffuni wrote: On 02/12/15 17:44, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 22:34 , Pedro Giffuni wrote: ... Thank you! This will sound strange but I can't confirm, and I can't see anything obviously wrong. I have

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

2015-02-12 Thread Garrett Cooper
On Feb 12, 2015, at 15:14, Pedro Giffuni wrote: > On 02/12/15 17:44, Bjoern A. Zeeb wrote: >>> On 12 Feb 2015, at 22:34 , Pedro Giffuni wrote: ... > Thank you! > > This will sound strange but I can't confirm, and I can't see anything > obviously wrong. > > I have the revert ready but let me

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

2015-02-12 Thread Pedro Giffuni
On 02/12/15 17:44, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 22:34 , Pedro Giffuni wrote: On 02/12/15 17:27, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: Author: pfg Date: Thu Feb 12 21:07:42 2015 New Revision: 278634 URL: https://svnweb.freebsd.org/changeset/bas

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

2015-02-12 Thread Bjoern A. Zeeb
> On 12 Feb 2015, at 22:34 , Pedro Giffuni wrote: > > > On 02/12/15 17:27, Bjoern A. Zeeb wrote: >>> On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: >>> >>> Author: pfg >>> Date: Thu Feb 12 21:07:42 2015 >>> New Revision: 278634 >>> URL: https://svnweb.freebsd.org/changeset/base/278634 >>>

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

2015-02-12 Thread Pedro Giffuni
On 02/12/15 17:27, Bjoern A. Zeeb wrote: On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: Author: pfg Date: Thu Feb 12 21:07:42 2015 New Revision: 278634 URL: https://svnweb.freebsd.org/changeset/base/278634 Log: ulimit(3): Fix broken check. The existing implementation had a broken com

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

2015-02-12 Thread Bjoern A. Zeeb
> On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: > > Author: pfg > Date: Thu Feb 12 21:07:42 2015 > New Revision: 278634 > URL: https://svnweb.freebsd.org/changeset/base/278634 > > Log: > ulimit(3): Fix broken check. > > The existing implementation had a broken comparison that could over

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

2015-02-12 Thread Pedro F. Giffuni
Author: pfg Date: Thu Feb 12 21:07:42 2015 New Revision: 278634 URL: https://svnweb.freebsd.org/changeset/base/278634 Log: ulimit(3): Fix broken check. The existing implementation had a broken comparison that could overflow. Replace this with a check that avoids the overflow before it hap