Thread View: comp.bugs.2bsd
1 messages
1 total messages
Started by Steven M. Schultz
Sun, 17 Dec 1989 19:56
/etc/lpc uses NULL pointer
Author: Steven M. Schultz
Date: Sun, 17 Dec 1989 19:56
Date: Sun, 17 Dec 1989 19:56
74 lines
2507 bytes
2507 bytes
Subject: lpc references NULL pointer
Index: usr.lib/lpr/lpc.c 2.10BSD
Description:
Asking for help, either by "?" or "help" produces a parenthesized
'null' at the end of the command list (on a pdp-11) or possibly
a coredump on machines where NULL pointers are illegal. 'lpc' is not
checking properly for the end of the command list which is NULL
terminated.
Repeat-By:
# /etc/lpc
lpc> ?
Commands may be abbreviated. Commands are:
abort enable disable help restart status topq ?
clean exit down quit start stop up (null)
lpc> quit
#
The output SHOULD be:
# ./lpc
lpc> ?
Commands may be abbreviated. Commands are:
abort enable disable help restart status topq ?
clean exit down quit start stop up
lpc> quit
#
Fix:
Apply the patch below to lpc.c, there are two changes - the first
avoids doing "strlen" on a NULL pointer, the second prevents
using NULL in a "printf".
*** lpc.c.old Sun Feb 22 06:43:09 1987
--- lpc.c Sun Dec 17 14:24:25 1989
***************
*** 193,199 ****
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)
--- 193,199 ----
extern int NCMDS;
printf("Commands may be abbreviated. Commands are:\n\n");
! for (c = cmdtab; c->c_name; c++) {
int len = strlen(c->c_name);
if (len > width)
***************
*** 207,213 ****
for (i = 0; i < lines; i++) {
for (j = 0; j < columns; j++) {
c = cmdtab + j * lines + i;
! printf("%s", c->c_name);
if (c + lines >= &cmdtab[NCMDS]) {
printf("\n");
break;
--- 207,214 ----
for (i = 0; i < lines; i++) {
for (j = 0; j < columns; j++) {
c = cmdtab + j * lines + i;
! if (c->c_name)
! printf("%s", c->c_name);
if (c + lines >= &cmdtab[NCMDS]) {
printf("\n");
break;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads