Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/rasops Avoid shift-count overflow to fix strange cur...



details:   https://anonhg.NetBSD.org/src/rev/4274b22ae8cb
branches:  trunk
changeset: 1000425:4274b22ae8cb
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jul 24 18:40:01 2019 +0000

description:
Avoid shift-count overflow to fix strange cursor behaviors on amd64
when font width is odd.

diffstat:

 sys/dev/rasops/rasops.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (50 lines):

diff -r 86660c21c166 -r 4274b22ae8cb sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c   Wed Jul 24 18:33:49 2019 +0000
+++ b/sys/dev/rasops/rasops.c   Wed Jul 24 18:40:01 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rasops.c,v 1.82 2019/07/24 18:33:49 rin Exp $ */
+/*      $NetBSD: rasops.c,v 1.83 2019/07/24 18:40:01 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.82 2019/07/24 18:33:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.83 2019/07/24 18:40:01 rin Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -1081,9 +1081,6 @@
        } else {
                uint32_t tmp32, msk1, msk2;
 
-               msk1 = be32toh(0xffffffff >> (32 - (8 * slop1)));
-               msk2 = be32toh(0xffffffff << (32 - (8 * slop2)));
-
                while (height--) {
                        dp = (uint8_t *)((uintptr_t)rp & ~3);
                        rp += ri->ri_stride;
@@ -1092,7 +1089,9 @@
                                hrp += ri->ri_stride;
                        }
 
-                       if (msk1 != 0) {
+                       if (slop1) {
+                               msk1 =
+                                   be32toh(0xffffffff >> (32 - (8 * slop1)));
                                tmp32 = *(uint32_t *)dp ^ msk1;
                                *(uint32_t *)dp = tmp32;
                                dp += 4;
@@ -1112,7 +1111,9 @@
                                }
                        }
 
-                       if (msk2 != 0) {
+                       if (slop2) {
+                               msk2 =
+                                   be32toh(0xffffffff << (32 - (8 * slop2)));
                                tmp32 = *(uint32_t *)dp ^ msk2;
                                *(uint32_t *)dp = tmp32;
                                if (ri->ri_hwbits)



Home | Main Index | Thread Index | Old Index