Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jul 2001 04:41:47 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mike Barcroft <mike@q9media.com>
Cc:        audit@FreeBSD.org
Subject:   Re: src/bin/ed patch
Message-ID:  <Pine.BSF.4.21.0107020417590.33742-100000@besplex.bde.org>
In-Reply-To: <200107011506.f61F6P904227@coffee.q9media.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 1 Jul 2001, Mike Barcroft wrote:

> Bruce Evans <bde@zeta.org.au> writes:
> > On Fri, 29 Jun 2001, Mike Barcroft wrote:
> > > o Since the rcsids are generating warnings, switch to __RCSID().
> >
> > Please don't.  obrien and I are trying to decide whether ids (initially
> > in libc) should be changed to use __RCSID() when they are cleaned up.
> > I think we are unlikely to use it.  One problem is that it is also used
> > in other BSDs, so it can't be used to hide messy ifdefs to control the
> > visibility of the id string in a system-dependent way.
> 
> Why not just add a switch in /etc/{defaults/,}make.conf to allow one
> to control the visibility of RCSIDs?  What concern is it of ours if the
> other BSDs embed RCSIDs unconditionally?

It would be silly to have a switch to fully control FreeBSD rcsids if
OtherBSD rcsids get embedded (in object files) unconditionally.

> In any event, __RCSID() doesn't appear ready for general use.  An
> updated version of my patch is available at the end of this message
> and also at: http://testbed.q9media.net/freebsd/ed.20010701.patch

Thanks.  I like most of this version.

> Index: ed/main.c
> ===================================================================
> RCS file: /home/ncvs/src/bin/ed/main.c,v
> retrieving revision 1.20
> diff -u -r1.20 main.c
> --- ed/main.c	2001/06/28 22:06:27	1.20
> +++ ed/main.c	2001/07/01 14:29:06
> @@ -27,18 +27,10 @@
>   */
>  
>  #ifndef lint
> -static char * const copyright =
> -"@(#) Copyright (c) 1993 Andrew Moore, Talke Studio. \n\
> - All rights reserved.\n";
> -#endif /* not lint */
> -
> -#ifndef lint
> -#if 0
> -static char * const rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
> -#else
> -static char * const rcsid =
> +static const char copyright[] =
> +  "@(#) Copyright (c) 1993 Andrew Moore, Talke Studio.  All rights reserved.";
> +static const char rcsid[] =
>    "$FreeBSD: src/bin/ed/main.c,v 1.20 2001/06/28 22:06:27 dd Exp $";
> -#endif
>  #endif /* not lint */
>  
>  /*

Why change the original copyright string (source and oupput format)?
The copyright normally goes in a separate "#ifdef lint".

> ...
> @@ -1385,12 +1377,13 @@
>  {
>  	char *hup = NULL;		/* hup filename */
>  	char *s;
> +	char ed_hup[] = "ed.hup";
>  	int n;
>  
>  	if (!sigactive)
>  		quit(1);
>  	sigflags &= ~(1 << (signo - 1));
> -	if (addr_last && write_file("ed.hup", "w", 1, addr_last) < 0 &&
> +	if (addr_last && write_file(ed_hup, "w", 1, addr_last) < 0 &&
>  	    (s = getenv("HOME")) != NULL &&
>  	    (n = strlen(s)) + 8 <= PATH_MAX &&	/* "ed.hup" + '/' */
>  	    (hup = (char *) malloc(n + 10)) != NULL) {

The correct fix is to declare write_file()'s first arg as const.

BTW, I think we're only seeing the tip of the iceberg for constant
poisoning of function args.  -Wwrite-strings triggers a few warnings
for "char *" args, but there are zillions of interfaces that take
pointers to data that is not changed by the interface yet not declared
const.  Change a top-level interface to declare things as const and
the poison will spread to lower levels.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0107020417590.33742-100000>