Fix handling of control and non-ascii charachters. Print a space

instead of what happens to be at that position (out of bounds)
in the char array. Prompted by OpenBSD PR/3147.
This commit is contained in:
mjl 2003-03-13 12:13:43 +00:00
parent f2746edc5b
commit 79ea3ffca9
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: banner.c,v 1.8 2003/03/13 11:57:23 mjl Exp $ */
/* $NetBSD: banner.c,v 1.9 2003/03/13 12:13:43 mjl Exp $ */
/*
* Changes for banner(1)
@ -62,7 +62,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)printjob.c 8.2 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: banner.c,v 1.8 2003/03/13 11:57:23 mjl Exp $");
__RCSID("$NetBSD: banner.c,v 1.9 2003/03/13 12:13:43 mjl Exp $");
#endif
#endif /* not lint */
@ -142,7 +142,10 @@ scan_out(int scfd, char *scsp, int dlm)
*strp++ = BackGnd;
sp = scsp;
for (nchrs = 0; *sp != dlm && *sp != '\0'; ) {
d = dropit(c = TRC(cc = *sp++));
cc = *sp++;
if(cc < ' ' || cc > 0x7f)
cc = ' ';
d = dropit(c = TRC(cc));
if ((!d && scnhgt > HEIGHT) || (scnhgt <= Drop && d))
for (j = WIDTH; --j;)
*strp++ = BackGnd;