Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!sri-spam!mordor!lll-tis!elxsi!marduk!gww From: gww@marduk.UUCP (Gary Winiger) Newsgroups: comp.bugs.4bsd Subject: lpc help command dereferences a null pointer. +Fix Message-ID: <519@elxsi.UUCP> Date: Fri, 4-Sep-87 18:13:28 EDT Article-I.D.: elxsi.519 Posted: Fri Sep 4 18:13:28 1987 Date-Received: Sat, 5-Sep-87 21:26:18 EDT Sender: nobody@elxsi.UUCP Reply-To: gww@marduk.UUCP (Gary Winiger) Organization: ELXSI Super Computers, San Jose Lines: 66 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)