Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/banner Fix handling of control and non-ascii charach...



details:   https://anonhg.NetBSD.org/src/rev/3502907f2270
branches:  trunk
changeset: 544157:3502907f2270
user:      mjl <mjl%NetBSD.org@localhost>
date:      Thu Mar 13 12:13:43 2003 +0000

description:
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.

diffstat:

 usr.bin/banner/banner.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 6e76f609c5c7 -r 3502907f2270 usr.bin/banner/banner.c
--- a/usr.bin/banner/banner.c   Thu Mar 13 12:02:54 2003 +0000
+++ b/usr.bin/banner/banner.c   Thu Mar 13 12:13:43 2003 +0000
@@ -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 @@
 #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 @@
                    *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;



Home | Main Index | Thread Index | Old Index