Date: Fri, 29 Jun 2001 00:28:00 -0400 (EDT) From: Mike Barcroft <mike@q9media.com> To: audit@FreeBSD.org Subject: src/bin/ed patch Message-ID: <200106290428.f5T4S0C97998@coffee.q9media.com>
next in thread | raw e-mail | index | archive | help
I would appreciate it if someone would review and commit the patch at the end of this message. Also available at: http://testbed.q9media.net/freebsd/ed.20010628.patch Best regards, Mike Barcroft ----------------------------------------------------------------------- ed.20010628.patch o Since the rcsids are generating warnings, switch to __RCSID(). o Add consts where appropriate. o Rename some variables that are shadowing global declarations. o Set WARNS?=2 Index: ed/Makefile =================================================================== RCS file: /home/ncvs/src/bin/ed/Makefile,v retrieving revision 1.18 diff -u -r1.18 Makefile --- ed/Makefile 2000/02/29 11:39:24 1.18 +++ ed/Makefile 2001/06/29 04:05:43 @@ -1,6 +1,7 @@ # $FreeBSD: src/bin/ed/Makefile,v 1.18 2000/02/29 11:39:24 markm Exp $ PROG= ed +WARNS?= 2 SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c LINKS= ${BINDIR}/ed ${BINDIR}/red MLINKS= ed.1 red.1 Index: ed/buf.c =================================================================== RCS file: /home/ncvs/src/bin/ed/buf.c,v retrieving revision 1.17 diff -u -r1.17 buf.c --- ed/buf.c 1999/08/27 23:14:12 1.17 +++ ed/buf.c 2001/06/29 04:05:43 @@ -24,15 +24,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/buf.c,v 1.17 1999/08/27 23:14:12 peter Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/buf.c,v 1.17 1999/08/27 23:14:12 peter Exp $"); #endif /* not lint */ #include <sys/file.h> Index: ed/cbc.c =================================================================== RCS file: /home/ncvs/src/bin/ed/cbc.c,v retrieving revision 1.13 diff -u -r1.13 cbc.c --- ed/cbc.c 2001/03/05 02:15:37 1.13 +++ ed/cbc.c 2001/06/29 04:05:43 @@ -35,15 +35,12 @@ * SUCH DAMAGE. * * from: @(#)bdes.c 5.5 (Berkeley) 6/27/91 + * @(#)cbc.c,v 1.2 1994/02/01 00:34:36 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)cbc.c,v 1.2 1994/02/01 00:34:36 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/cbc.c,v 1.13 2001/03/05 02:15:37 kris Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/cbc.c,v 1.13 2001/03/05 02:15:37 kris Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -209,7 +206,7 @@ */ void des_error(s) - char *s; /* the message */ + const char *s; /* the message */ { (void)sprintf(errmsg, "%s", s ? s : strerror(errno)); } @@ -250,9 +247,9 @@ * convert the key to a bit pattern */ void -expand_des_key(obuf, ibuf) +expand_des_key(obuf, kbuf) char *obuf; /* bit pattern */ - char *ibuf; /* the key itself */ + char *kbuf; /* the key itself */ { register int i, j; /* counter in a for loop */ int nbuf[64]; /* used for hex/key translation */ @@ -260,13 +257,13 @@ /* * leading '0x' or '0X' == hex key */ - if (ibuf[0] == '0' && (ibuf[1] == 'x' || ibuf[1] == 'X')) { - ibuf = &ibuf[2]; + if (kbuf[0] == '0' && (kbuf[1] == 'x' || kbuf[1] == 'X')) { + kbuf = &kbuf[2]; /* * now translate it, bombing on any illegal hex digit */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = hex_to_binary((int) ibuf[i], 16)) == -1) + for (i = 0; kbuf[i] && i < 16; i++) + if ((nbuf[i] = hex_to_binary((int) kbuf[i], 16)) == -1) des_error("bad hex digit in key"); while (i < 16) nbuf[i++] = 0; @@ -280,13 +277,13 @@ /* * leading '0b' or '0B' == binary key */ - if (ibuf[0] == '0' && (ibuf[1] == 'b' || ibuf[1] == 'B')) { - ibuf = &ibuf[2]; + if (kbuf[0] == '0' && (kbuf[1] == 'b' || kbuf[1] == 'B')) { + kbuf = &kbuf[2]; /* * now translate it, bombing on any illegal binary digit */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = hex_to_binary((int) ibuf[i], 2)) == -1) + for (i = 0; kbuf[i] && i < 16; i++) + if ((nbuf[i] = hex_to_binary((int) kbuf[i], 2)) == -1) des_error("bad binary digit in key"); while (i < 64) nbuf[i++] = 0; @@ -300,7 +297,7 @@ /* * no special leader -- ASCII */ - (void)strncpy(obuf, ibuf, 8); + (void)strncpy(obuf, kbuf, 8); } /***************** @@ -391,7 +388,7 @@ char *msgbuf; /* I/O buffer */ FILE *fp; /* input file descriptor */ { - Desbuf ibuf; /* temp buffer for initialization vector */ + Desbuf tbuf; /* temp buffer for initialization vector */ register int n; /* number of bytes actually read */ register int c; /* used to test for EOF */ int inverse = 1; /* 0 to encrypt, 1 to decrypt */ @@ -400,11 +397,11 @@ /* * do the transformation */ - MEMCPY(BUFFER(ibuf), BUFFER(msgbuf), 8); + MEMCPY(BUFFER(tbuf), BUFFER(msgbuf), 8); DES_XFORM(UBUFFER(msgbuf)); for (c = 0; c < 8; c++) UCHAR(msgbuf, c) ^= UCHAR(ivec, c); - MEMCPY(BUFFER(ivec), BUFFER(ibuf), 8); + MEMCPY(BUFFER(ivec), BUFFER(tbuf), 8); /* * if the last one, handle it specially */ Index: ed/ed.h =================================================================== RCS file: /home/ncvs/src/bin/ed/ed.h,v retrieving revision 1.14 diff -u -r1.14 ed.h --- ed/ed.h 2001/05/29 18:03:13 1.14 +++ ed/ed.h 2001/06/29 04:05:44 @@ -200,7 +200,7 @@ int close_sbuf __P((void)); int copy_lines __P((long)); int delete_lines __P((long, long)); -void des_error __P((char *)); +void des_error __P((const char *)); int display_lines __P((long, long, int)); line_t *dup_line_node __P((line_t *)); int exec_command __P((void)); @@ -236,7 +236,7 @@ int join_lines __P((long, long)); int mark_line_node __P((line_t *, int)); int move_lines __P((long)); -line_t *next_active_node __P(()); +line_t *next_active_node __P((void)); long next_addr __P((void)); int open_sbuf __P((void)); char *parse_char_class __P((char *)); @@ -259,7 +259,7 @@ char *translit_text __P((char *, int, int, int)); void unmark_line_node __P((line_t *)); void unset_active_nodes __P((line_t *, line_t *)); -long write_file __P((char *, char *, long, long)); +long write_file __P((char *, const char *, long, long)); long write_stream __P((FILE *, long, long)); /* global buffers */ Index: ed/glbl.c =================================================================== RCS file: /home/ncvs/src/bin/ed/glbl.c,v retrieving revision 1.10 diff -u -r1.10 glbl.c --- ed/glbl.c 2000/10/16 07:06:35 1.10 +++ ed/glbl.c 2001/06/29 04:05:44 @@ -24,15 +24,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/glbl.c,v 1.10 2000/10/16 07:06:35 brian Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/glbl.c,v 1.10 2000/10/16 07:06:35 brian Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -210,7 +208,7 @@ /* next_active_node: return the next global-active line node */ line_t * -next_active_node() +next_active_node(void) { while (active_ptr < active_last && active_list[active_ptr] == NULL) active_ptr++; Index: ed/io.c =================================================================== RCS file: /home/ncvs/src/bin/ed/io.c,v retrieving revision 1.10 diff -u -r1.10 io.c --- ed/io.c 1999/08/27 23:14:14 1.10 +++ ed/io.c 2001/06/29 04:05:44 @@ -23,15 +23,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/io.c,v 1.10 1999/08/27 23:14:14 peter Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/io.c,v 1.10 1999/08/27 23:14:14 peter Exp $"); #endif /* not lint */ #include "ed.h" @@ -157,7 +155,7 @@ long write_file(fn, mode, n, m) char *fn; - char *mode; + const char *mode; long n; long m; { 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/06/29 04:05:44 @@ -24,21 +24,15 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp */ -#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 = - "$FreeBSD: src/bin/ed/main.c,v 1.20 2001/06/28 22:06:27 dd Exp $"; -#endif +#include <sys/cdefs.h> +__COPYRIGHT("@(#) Copyright (c) 1993 Andrew Moore, Talke Studio. \ +All rights reserved."); +__RCSID("$FreeBSD: src/bin/ed/main.c,v 1.20 2001/06/28 22:06:27 dd Exp $"); #endif /* not lint */ /* @@ -100,8 +94,8 @@ long current_addr; /* current address in editor buffer */ long addr_last; /* last address in editor buffer */ int lineno; /* script line number */ -char *prompt; /* command-line prompt */ -char *dps = "*"; /* default command-line prompt */ +const char *prompt; /* command-line prompt */ +const char *dps = "*"; /* default command-line prompt */ const char usage[] = "usage: %s [-] [-sx] [-p string] [name]\n"; @@ -1385,12 +1379,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) { Index: ed/re.c =================================================================== RCS file: /home/ncvs/src/bin/ed/re.c,v retrieving revision 1.16 diff -u -r1.16 re.c --- ed/re.c 2001/05/29 18:03:14 1.16 +++ ed/re.c 2001/06/29 04:05:44 @@ -24,15 +24,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/re.c,v 1.16 2001/05/29 18:03:14 imp Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/re.c,v 1.16 2001/05/29 18:03:14 imp Exp $"); #endif /* not lint */ #include "ed.h" Index: ed/sub.c =================================================================== RCS file: /home/ncvs/src/bin/ed/sub.c,v retrieving revision 1.12 diff -u -r1.12 sub.c --- ed/sub.c 1999/08/27 23:14:15 1.12 +++ ed/sub.c 2001/06/29 04:05:45 @@ -24,15 +24,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)sub.c,v 1.1 1994/02/01 00:34:44 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)sub.c,v 1.1 1994/02/01 00:34:44 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/sub.c,v 1.12 1999/08/27 23:14:15 peter Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/sub.c,v 1.12 1999/08/27 23:14:15 peter Exp $"); #endif /* not lint */ #include "ed.h" Index: ed/undo.c =================================================================== RCS file: /home/ncvs/src/bin/ed/undo.c,v retrieving revision 1.9 diff -u -r1.9 undo.c --- ed/undo.c 1999/08/27 23:14:15 1.9 +++ ed/undo.c 2001/06/29 04:05:45 @@ -23,15 +23,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)undo.c,v 1.1 1994/02/01 00:34:44 alm Exp */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)undo.c,v 1.1 1994/02/01 00:34:44 alm Exp"; -#else -static char * const rcsid = - "$FreeBSD: src/bin/ed/undo.c,v 1.9 1999/08/27 23:14:15 peter Exp $"; -#endif +#include <sys/cdefs.h> +__RCSID("$FreeBSD: src/bin/ed/undo.c,v 1.9 1999/08/27 23:14:15 peter Exp $"); #endif /* not lint */ #include "ed.h" 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?200106290428.f5T4S0C97998>