From owner-svn-src-all@FreeBSD.ORG Fri Feb 13 17:37:28 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 F15DD65C for ; Fri, 13 Feb 2015 17:37:28 +0000 (UTC) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) (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 89538FC1 for ; Fri, 13 Feb 2015 17:37:28 +0000 (UTC) Received: by mail-wi0-f170.google.com with SMTP id hi2so13607271wib.1 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=hMCR0TGFnSBLJFAcbdV4qVqYiyvM+P7Ppo3LqPEY3payzWgE1BcoS2XIh7PN3fIJqj lt7LfiAhbZwSbQ42p/FJFtB/y37gxSfR279cVS/F+u0KC1Pbht+5cIRxZ3Btgy2BfPm3 bSTrR81abW8bF51wssoCdnDEfveHJX+ACCydDe3Kz1wLAQ4Niwg6/nfWu4pNcBSQfb/Z FCkIHTiNVr75OIhg+/+/c2WbE57QM8Ic5rSUt21Ac01drtp6IP0+Coi28w9aERekg1x0 wpUpiJfqUwPFCry4rlt8l1jsfyiDQo5/CAXKYqyedgaJmFgE07v3EnC6K6ghPm+MxD1q Cpvg== X-Gm-Message-State: ALoCoQklcskbswwtpJFe3UtCnI9ToJAd3H3RQYmNut8xS+5aBvLOzZeEyzveoT4pQzGnM1AISOJ0 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-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: Fri, 13 Feb 2015 17:37:29 -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/