summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authorrodrigc <rodrigc@FreeBSD.org>2005-08-30 18:58:17 +0000
committerrodrigc <rodrigc@FreeBSD.org>2005-08-30 18:58:17 +0000
commit202872e9e687e8cc11a6302ad1aa8d0781556ccd (patch)
tree7796a5bca15fb24807fcf1b8d8fa3f0b68805a4b /sys/dev/syscons
parent40d25976f11fbf40e8b37a57763c0e2a223bc034 (diff)
downloadFreeBSD-src-202872e9e687e8cc11a6302ad1aa8d0781556ccd.zip
FreeBSD-src-202872e9e687e8cc11a6302ad1aa8d0781556ccd.tar.gz
Prevent division by zero errors in sc_mouse_move()
by explicitly setting sc->font_width, in the same places where sc->font_size is set, instead of relying on the default initialized value of 0 for sc->font_width. PR: kern/84836 Reported by: Andrey V. Elsukov <bu7cher at yandex dot ru> MFC after: 2 days
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/scmouse.c2
-rw-r--r--sys/dev/syscons/scvesactl.c4
-rw-r--r--sys/dev/syscons/scvidctl.c14
-rw-r--r--sys/dev/syscons/syscons.c4
-rw-r--r--sys/dev/syscons/syscons.h7
5 files changed, 17 insertions, 14 deletions
diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c
index bec8f74..794a4ba 100644
--- a/sys/dev/syscons/scmouse.c
+++ b/sys/dev/syscons/scmouse.c
@@ -126,7 +126,7 @@ sc_mouse_move(scr_stat *scp, int x, int y)
s = spltty();
scp->mouse_xpos = scp->mouse_oldxpos = x;
scp->mouse_ypos = scp->mouse_oldypos = y;
- if (scp->font_size <= 0)
+ if (scp->font_size <= 0 || scp->font_width <= 0)
scp->mouse_pos = scp->mouse_oldpos = 0;
else
scp->mouse_pos = scp->mouse_oldpos =
diff --git a/sys/dev/syscons/scvesactl.c b/sys/dev/syscons/scvesactl.c
index a39bf48..a556dc0 100644
--- a/sys/dev/syscons/scvesactl.c
+++ b/sys/dev/syscons/scvesactl.c
@@ -70,7 +70,7 @@ vesa_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *
case SW_TEXT_132x60:
if (!(scp->sc->adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
- return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
+ return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0);
/* text modes */
case SW_VESA_C80x60:
@@ -81,7 +81,7 @@ vesa_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *
if (!(scp->sc->adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
mode = (cmd & 0xff) + M_VESA_BASE;
- return sc_set_text_mode(scp, tp, mode, 0, 0, 0);
+ return sc_set_text_mode(scp, tp, mode, 0, 0, 0, 0);
/* graphics modes */
case SW_VESA_32K_320: case SW_VESA_64K_320:
diff --git a/sys/dev/syscons/scvidctl.c b/sys/dev/syscons/scvidctl.c
index 785067d..62d46c2 100644
--- a/sys/dev/syscons/scvidctl.c
+++ b/sys/dev/syscons/scvidctl.c
@@ -133,7 +133,7 @@ typedef struct old_video_info {
int
sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
- int fontsize)
+ int fontsize, int fontwidth)
{
video_info_t info;
u_char *font;
@@ -213,6 +213,7 @@ sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
scp->ypixel = scp->ysize*fontsize;
scp->font = font;
scp->font_size = fontsize;
+ scp->font_width = fontwidth;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
@@ -317,7 +318,7 @@ sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
- int fontsize)
+ int fontsize, int fontwidth)
{
#ifndef SC_PIXEL_MODE
return ENODEV;
@@ -429,6 +430,7 @@ sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
scp->yoff = (scp->ypixel/fontsize - ysize)/2;
scp->font = font;
scp->font_size = fontsize;
+ scp->font_width = fontwidth;
/* allocate buffers */
sc_alloc_scr_buffer(scp, TRUE, TRUE);
@@ -554,7 +556,7 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
if (info.vi_flags & V_INFO_GRAPHICS)
return sc_set_graphics_mode(scp, tp, *(int *)data);
else
- return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0);
+ return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0, 0);
#endif /* SC_NO_MODE_CHANGE */
case OLD_CONS_MODEINFO: /* get mode information (old infterface) */
@@ -653,7 +655,7 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
#endif
if (!(adp->va_flags & V_ADP_MODECHANGE))
return ENODEV;
- return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
+ return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0);
/* GRAPHICS MODES */
case SW_BG320: case SW_BG640:
@@ -746,7 +748,7 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
return EINVAL;
if (scp->status & GRAPHICS_MODE)
return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
- scp->font_size);
+ scp->font_size, scp->font_width);
s = spltty();
if ((error = sc_clean_up(scp))) {
splx(s);
@@ -789,7 +791,7 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
return ENODEV;
return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
- ((int *)data)[2]);
+ ((int *)data)[2], 8);
#endif /* SC_PIXEL_MODE */
case KDGETMODE: /* get current mode of this (virtual) console */
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 8daca00..5c8b843 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -358,7 +358,7 @@ sc_attach_unit(int unit, int flags)
splash_term(sc->adp);
#endif
sc_set_graphics_mode(scp, NULL, M_VESA_800x600);
- sc_set_pixel_mode(scp, NULL, COL, ROW, 16);
+ sc_set_pixel_mode(scp, NULL, COL, ROW, 16, 8);
sc->initial_mode = M_VESA_800x600;
#ifdef DEV_SPLASH
/* put up the splash again! */
@@ -510,7 +510,7 @@ scopen(struct cdev *dev, int flag, int mode, struct thread *td)
if (scp == NULL) {
scp = SC_STAT(dev) = alloc_scp(sc, SC_VTY(dev));
if (ISGRAPHSC(scp))
- sc_set_pixel_mode(scp, NULL, COL, ROW, 16);
+ sc_set_pixel_mode(scp, NULL, COL, ROW, 16, 8);
}
if (!tp->t_winsize.ws_col && !tp->t_winsize.ws_row) {
tp->t_winsize.ws_col = scp->xsize;
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 460d3c5..542f301 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -606,10 +606,11 @@ int sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
/* scvidctl.c */
int sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
- int xsize, int ysize, int fontsize);
+ int xsize, int ysize, int fontsize,
+ int font_width);
int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
-int sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
- int xsize, int ysize, int fontsize);
+int sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize,
+ int ysize, int fontsize, int font_width);
int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
struct thread *td);
OpenPOWER on IntegriCloud