From owner-svn-src-all@FreeBSD.ORG Thu Feb 12 22:28:15 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0FC3086D; Thu, 12 Feb 2015 22:28:15 +0000 (UTC) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B5F8D6DA; Thu, 12 Feb 2015 22:28:14 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id A286925D3A92; Thu, 12 Feb 2015 22:28:04 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id D69E3C770A1; Thu, 12 Feb 2015 22:28:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id 0aNImd3SHO0O; Thu, 12 Feb 2015 22:28:02 +0000 (UTC) Received: from [IPv6:fde9:577b:c1a9:4410:ccda:6447:f:a] (unknown [IPv6:fde9:577b:c1a9:4410:ccda:6447:f:a]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 67B96C7709E; Thu, 12 Feb 2015 22:28:01 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Subject: Re: svn commit: r278634 - head/lib/libc/gen From: "Bjoern A. Zeeb" In-Reply-To: <201502122107.t1CL7gaO004041@svn.freebsd.org> Date: Thu, 12 Feb 2015 22:27:41 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201502122107.t1CL7gaO004041@svn.freebsd.org> To: "Pedro F. Giffuni" X-Mailer: Apple Mail (2.2070.6) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2015 22:28:15 -0000 > On 12 Feb 2015, at 21:07 , Pedro F. Giffuni wrote: >=20 > Author: pfg > Date: Thu Feb 12 21:07:42 2015 > New Revision: 278634 > URL: https://svnweb.freebsd.org/changeset/base/278634 >=20 > Log: > ulimit(3): Fix broken check. >=20 > The existing implementation had a broken comparison that could = overflow. > Replace this with a check that avoids the overflow before it happens. >=20 > Consistently return a maximum value also on the case of negative > arguments since negative is considered an overflow and means > infinity for our current setrlimit(). >=20 > Discussed with: bde (rather extensively) >=20 Did this compile? > CID: 1199295 > MFC after: 1 week >=20 > Modified: > head/lib/libc/gen/ulimit.c >=20 > Modified: head/lib/libc/gen/ulimit.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/lib/libc/gen/ulimit.c Thu Feb 12 20:57:57 2015 = (r278633) > +++ head/lib/libc/gen/ulimit.c Thu Feb 12 21:07:42 2015 = (r278634) > @@ -53,13 +53,13 @@ ulimit(int cmd, ...) > va_start(ap, cmd); > arg =3D va_arg(ap, long); > va_end(ap); > + if (arg > RLIM_INFINITY / 512 || arg < 0) > + arg =3D RLIM_INFINITY / 512; > limit.rlim_max =3D limit.rlim_cur =3D (rlim_t)arg * 512; >=20 > /* The setrlimit() function sets errno to EPERM if = needed. */ > if (setrlimit(RLIMIT_FSIZE, &limit) =3D=3D -1) > return (-1); > - if (arg * 512 > LONG_MAX) > - return (LONG_MAX); > return (arg); > } else { > errno =3D EINVAL; >=20 =E2=80=94=20 Bjoern A. Zeeb Charles Haddon Spurgeon: "Friendship is one of the sweetest joys of life. Many might have failed beneath the bitterness of their trial had they not found a friend."