From owner-freebsd-audit Mon Nov 27 8:33:36 2000 Delivered-To: freebsd-audit@freebsd.org Received: from mout0.freenet.de (mout0.freenet.de [194.97.50.131]) by hub.freebsd.org (Postfix) with ESMTP id DA64337B479; Mon, 27 Nov 2000 08:33:32 -0800 (PST) Received: from [194.97.50.144] (helo=mx1.freenet.de) by mout0.freenet.de with esmtp (Exim 3.16 #20) id 140RDe-0004Ou-00; Mon, 27 Nov 2000 17:33:30 +0100 Received: from a31f0.pppool.de ([213.6.49.240] helo=Magelan.Leidinger.net) by mx1.freenet.de with esmtp (Exim 3.16 #20) id 140RDe-0002hi-00; Mon, 27 Nov 2000 17:33:30 +0100 Received: from Leidinger.net (netchild@localhost [127.0.0.1]) by Magelan.Leidinger.net (8.11.1/8.11.1) with ESMTP id eARGOir89679; Mon, 27 Nov 2000 17:24:45 +0100 (CET) (envelope-from netchild@Leidinger.net) Message-Id: <200011271624.eARGOir89679@Magelan.Leidinger.net> Date: Mon, 27 Nov 2000 17:24:42 +0100 (CET) From: Alexander Leidinger Subject: Re: gcc __attributes for format strings To: kris@FreeBSD.ORG Cc: audit@FreeBSD.ORG In-Reply-To: <20001126222048.A46809@citusc17.usc.edu> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 26 Nov, Kris Kennaway wrote: > Okay, looks like we can play with some gcc attributes to flag things > as format strings. For example: > > Index: create_chunk.c > =================================================================== > RCS file: /mnt/ncvs/src/lib/libdisk/create_chunk.c,v > retrieving revision 1.54 > diff -u -r1.54 create_chunk.c > --- create_chunk.c 2000/11/06 23:15:01 1.54 > +++ create_chunk.c 2000/11/27 06:14:00 > @@ -28,6 +28,8 @@ > #include > #include "libdisk.h" > > +static void msgDebug(char *, ...) __printf0like(1,0); > + > /* Clone these two from sysinstall because we need our own copies > * due to link order problems with `crunch'. Feh! > */ > > __printf0like(a,b) says "treat argument 'a' as a printf format string > which may be null, and arguments starting with 'b' are the arguments > to the format string". b=0 is for the case of a varargs function like > above. From gcc.info (on -current): ---snip--- `format (ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)' The `format' attribute specifies that a function takes `printf', `scanf', or `strftime' style arguments which should be type-checked against a format string. For example, the declaration: extern int my_printf (void *my_object, const char *my_format, ...) __attribute__ ((format (printf, 2, 3))); causes the compiler to check the arguments in calls to `my_printf' for consistency with the `printf' style format string argument `my_format'. [...] ---snip--- A search in gcc.info for printflike didn't show a match. Bye, Alexander. -- Reboot America. http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = 7423 F3E6 3A7E B334 A9CC B10A 1F5F 130A A638 6E7E To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message