From owner-svn-src-head@FreeBSD.ORG Fri Feb 13 17:37:22 2015 Return-Path: Delivered-To: svn-src-head@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 DE492568 for ; Fri, 13 Feb 2015 17:37:22 +0000 (UTC) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70222FBE for ; Fri, 13 Feb 2015 17:37:22 +0000 (UTC) Received: by mail-wi0-f178.google.com with SMTP id em10so13806052wid.5 for ; Fri, 13 Feb 2015 09:37:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=MjfUn5/Yua0Y4hAHzYSRJxn4ihXWwTkQ0d583IPBVys=; b=kXYD6Su0AwxNo+8p18BCYr16cuFMcTklQ9ul3aJt2NORI7cThQ+sTrs9r/G0hce57Y JVEz9ZElGz315f2XJ/CAYpCU/sErzasQOGvF9Nn/HHwU4FcpM+WM9nxymMa49OzAns5J NN/7rqyHJA4zEyIzvUvnn0bAKLMubQdFP3oW18LT6X3ZDq9EK1xD5uksMvRfKoDknnuh mKyy/LksBGetNcBPzXCyxNM4CQ05fiIoodeNSC/qVZQiD8nj61ATLBuQ0ExaRN3L269h tNFMq2n/2QhMXWWhYHuKUTXMgIQui8krRte6akERJrBScW3mGy9ZV01IEEBdy+vONAVK n/HA== X-Gm-Message-State: ALoCoQld53OZhleiI1BPwO2Y/i3i0Kntsqs4CGl/u06tEwrSSPjEVO6M2g4wHuRXhQ12jUaxVopY X-Received: by 10.180.78.4 with SMTP id x4mr9210518wiw.86.1423849040662; Fri, 13 Feb 2015 09:37:20 -0800 (PST) Received: from [46.246.76.54] ([46.246.76.54]) by mx.google.com with ESMTPSA id uo6sm10900004wjc.49.2015.02.13.09.37.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Feb 2015 09:37:19 -0800 (PST) Message-ID: <54DE364E.4060203@freebsd.org> Date: Fri, 13 Feb 2015 20:37:18 +0300 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bruce Evans Subject: Re: svn commit: r278634 - head/lib/libc/gen References: <201502122107.t1CL7gaO004041@svn.freebsd.org> <54DD2A87.2050008@FreeBSD.org> <9A683D99-C1E9-4736-982C-69F583D3A40D@FreeBSD.org> <20150213172738.C1007@besplex.bde.org> <54DDABF2.9000201@freebsd.org> <54DDAEF6.3060900@freebsd.org> <20150214005543.X2210@besplex.bde.org> In-Reply-To: <20150214005543.X2210@besplex.bde.org> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, "Bjoern A. Zeeb" , Pedro Giffuni , src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2015 17:37:23 -0000 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 to RLIM_INFINITY. In > 4.4BSD, it doesn't even check for negative args, and mostly stores > them unchanged; then undefined behaviour tends to occur when the > stored values are used without further checking.) This hack should be removed from setrlimit() to catch real error. Any syscall should do basic arguments validation. This is true about ulimit() too, so it is not a syscall. If overflow happens before passing arg, it is better to report it than to convert blindly to RLIM_INFINITY. Somebody may decrement long limit value by fixed chunks and go beyond zero. I.e. situation is completely opposite: he means 0 limit, but you set it to INFINITY. So it is always better to report error to leave caller deal with it. If he needs a bigger than long limit, he should use setrlimit() directly, not ulimit(). -- http://ache.vniz.net/