gww@marduk.UUCP (Gary Winiger) (09/05/87)
Subject: The lpc help command dereferences a null pointer. +Fix
Index: usr.lib/lpr/lpc.c 4.3BSD +Fix
Description:
When printing help from lpc the null pointer at the end of the
command table is dereferenced.
Repeat-By:
Bring up lpc, type ? and watch it core dump on a system which
does not permit null pointer dereferencing.
Fix:
NCMDS is the number of commands in the cmdtab, including the
null command that ends the table.
In the help command, stop printing at NCMDS-1.
The attached code solves this problem at Elxsi.
Gary..
{ucbvax!sun,lll-lcc!lll-tis,amdahl!altos86,bridge2}!elxsi!gww
--------- cut --------- snip --------- :.,$w diff -------------
*** /tmp/,RCSt1013466 Mon Jun 22 17:24:00 1987
--- lpc.c Mon Jun 22 17:23:36 1987
***************
*** 1,5 ****
--- 1,8 ----
/*
* $Log: lpc.c,v $
+ * Revision 1.2 87/06/22 17:23:10 gww
+ * Don't dereference the null pointer at the end of the command table.
+ *
* Revision 1.1 87/06/16 16:25:39 gww
* Initial revision
*
***************
*** 17,23 ****
#endif not lint
#ifndef lint
! static char *ERcsId = "$Header: lpc.c,v 1.1 87/06/16 16:25:39 gww Exp $ ENIX BSD";
static char sccsid[] = "@(#)lpc.c 5.2 (Berkeley) 11/17/85";
#endif not lint
--- 20,26 ----
#endif not lint
#ifndef lint
! static char *ERcsId = "$Header: lpc.c,v 1.2 87/06/22 17:23:10 gww Exp $ ENIX BSD";
static char sccsid[] = "@(#)lpc.c 5.2 (Berkeley) 11/17/85";
#endif not lint
***************
*** 197,203 ****
extern int NCMDS;
printf("Commands may be abbreviated. Commands are:\n\n");
! for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
int len = strlen(c->c_name);
if (len > width)
--- 200,206 ----
extern int NCMDS;
printf("Commands may be abbreviated. Commands are:\n\n");
! for (c = cmdtab; c < &cmdtab[NCMDS-1]; c++) {
int len = strlen(c->c_name);
if (len > width)