Module Name:    src
Committed By:   isaki
Date:           Sun Apr 28 14:44:46 UTC 2013

Modified Files:
        src/sys/arch/x68k/dev: ite_tv.c

Log Message:
Fix a kernel panic by printf(1).
The 2nd byte of ISO-2022-JP must be 0x21-0x7e.  Especially,
the character code less than 0x2121 causes SEGV, because a
font address points outside of the CGROM.
Reported by tsutsui@.  Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x68k/dev/ite_tv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/dev/ite_tv.c
diff -u src/sys/arch/x68k/dev/ite_tv.c:1.15 src/sys/arch/x68k/dev/ite_tv.c:1.16
--- src/sys/arch/x68k/dev/ite_tv.c:1.15	Sun Mar 11 06:01:05 2007
+++ src/sys/arch/x68k/dev/ite_tv.c	Sun Apr 28 14:44:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $	*/
+/*	$NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $	*/
 
 /*
  * Copyright (c) 1997 Masaru Oki.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -283,10 +283,10 @@ tv_putc_nm(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -312,10 +312,10 @@ tv_putc_in(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -341,10 +341,10 @@ tv_putc_bd(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -388,10 +388,10 @@ tv_putc_ul(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -425,10 +425,10 @@ tv_putc_bd_in(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -458,10 +458,10 @@ tv_putc_ul_in(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -495,10 +495,10 @@ tv_putc_bd_ul(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -542,10 +542,10 @@ tv_putc_bd_ul_in(struct ite_softc *ip, i
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;

Reply via email to