summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons/scvidctl.c
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/scvidctl.c
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/scvidctl.c')
-rw-r--r--sys/dev/syscons/scvidctl.c14
1 files changed, 8 insertions, 6 deletions
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 */
OpenPOWER on IntegriCloud