From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: check argument count in defcustom :safe? Date: Sun, 12 Apr 2015 06:45:04 +0000 Message-ID: References: <85a8yehdsn.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bacb40e6bebaa0513815684 X-Trace: ger.gmane.org 1428821113 26183 80.91.229.3 (12 Apr 2015 06:45:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Apr 2015 06:45:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier , Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 12 08:45:13 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YhBdo-0003Fw-Vq for ged-emacs-devel@m.gmane.org; Sun, 12 Apr 2015 08:45:13 +0200 Original-Received: from localhost ([::1]:44531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhBdo-00025r-Aa for ged-emacs-devel@m.gmane.org; Sun, 12 Apr 2015 02:45:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhBdk-00025k-NH for emacs-devel@gnu.org; Sun, 12 Apr 2015 02:45:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YhBdi-00008h-MW for emacs-devel@gnu.org; Sun, 12 Apr 2015 02:45:08 -0400 Original-Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:34155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhBdi-000059-Fh for emacs-devel@gnu.org; Sun, 12 Apr 2015 02:45:06 -0400 Original-Received: by widjs5 with SMTP id js5so42327418wid.1 for ; Sat, 11 Apr 2015 23:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=94Yi/JC8aC1IJS1g7xZV/VfO83KGT/igFCBREC1s4rI=; b=NTyp+QizbktxWTD7Ksyfk/6qQJ+AAvQllhtnh9z0GZ2KNGjEZAMl2EWs0AwP4N3QgX H5RlcC7aYj7u8/cvqEb6HVWjVH1foXL6oCO+FlYCwrnc/p7I12dUZZomtSuzNyDp/Dld 7rfitCvdfFxkG4mxtX8D5VlsteNGnx7mFzxyteOdRr6ds+/Ic2l1/RrgOPaLPVXig3TP s5LO6cBeUIDx7hDzVZ845AmMl/Uc0SpxMlRs6N8pSUwmZ9LlbMPH2rarwxBqY5/wHspL kh6dYf0zSriagkORBrE/DfBO5idZCAO7A0eyafkBNyByowiOeHoxvStSxFWJfHHy1Tir u0Bw== X-Received: by 10.194.60.4 with SMTP id d4mr17079443wjr.72.1428821105173; Sat, 11 Apr 2015 23:45:05 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:185322 Archived-At: --047d7bacb40e6bebaa0513815684 Content-Type: text/plain; charset=UTF-8 Stefan Monnier schrieb am So., 12. Apr. 2015 um 05:48 Uhr: > The number of arguments passed to a function is something that can be > easily checked by the function, but checking the number of arguments > accepted by a function is generally impossible (think of a function like > > (lambda (&rest args) > (if (> (length args) (if (halting-p (car args)) 2 3)) > (signal 'wrong-number-of-arguments 'foo (length args))) > ...) > But most functions are well-behaved and don't impose additional restrictions over those expressed in their parameter declaration; in these cases inspecting the argument list using help-function-arglist should work well enough. Agreed that using this as safe predicate is a security hole, the choices should just be normal symbols that are not used as functions. --047d7bacb40e6bebaa0513815684 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Stefan Monnier <monnier@iro.umontreal.ca> sc= hrieb am So., 12. Apr. 2015 um 05:48=C2=A0Uhr:
The number of arguments passed to a function is something that can be=
easily checked by the function, but checking the number of arguments
accepted by a function is generally impossible (think of a function like
=C2=A0 =C2=A0(lambda (&rest args)
=C2=A0 =C2=A0 =C2=A0(if (> (length args) (if (halting-p (car args)) 2 3)= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(signal 'wrong-number-of-arguments &#= 39;foo (length args)))
=C2=A0 =C2=A0 =C2=A0...)

But most functions are well-behaved and do= n't impose additional restrictions over those expressed in their parame= ter declaration; in these cases inspecting the argument list using help-fun= ction-arglist should work well enough.
Agreed that using this as = safe predicate is a security hole, the choices should just be normal symbol= s that are not used as functions.
--047d7bacb40e6bebaa0513815684--