Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi/acpica Avoid UB in OsdHardware.c



details:   https://anonhg.NetBSD.org/src/rev/2230da6f1d4d
branches:  trunk
changeset: 448955:2230da6f1d4d
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Feb 15 20:48:57 2019 +0000

description:
Avoid UB in OsdHardware.c

UBSan: Undefined Behavior in src/sys/dev/acpi/acpica/OsdHardware.c:265:17,
left shift of 255 by 24 places cannot be represented in type 'int'

This file isn't part of upstream acpica so just fix it locally.

Reported and initial patch by <Akul Pillai>

diffstat:

 sys/dev/acpi/acpica/OsdHardware.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r e0558ca850f0 -r 2230da6f1d4d sys/dev/acpi/acpica/OsdHardware.c
--- a/sys/dev/acpi/acpica/OsdHardware.c Fri Feb 15 18:57:15 2019 +0000
+++ b/sys/dev/acpi/acpica/OsdHardware.c Fri Feb 15 20:48:57 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: OsdHardware.c,v 1.10 2016/01/26 22:52:14 christos Exp $        */
+/*     $NetBSD: OsdHardware.c,v 1.11 2019/02/15 20:48:57 kamil Exp $   */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.10 2016/01/26 22:52:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.11 2019/02/15 20:48:57 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -262,13 +262,13 @@
        switch (Width) {
        case 8:
                tmp = pci_conf_read(pc, tag, Register & ~3);
-               tmp &= ~(0xff << ((Register & 3) * 8));
+               tmp &= ~(0xffu << ((Register & 3) * 8));
                tmp |= (Value << ((Register & 3) * 8));
                break;
 
        case 16:
                tmp = pci_conf_read(pc, tag, Register & ~3);
-               tmp &= ~(0xffff << ((Register & 3) * 8));
+               tmp &= ~(0xffffu << ((Register & 3) * 8));
                tmp |= (Value << ((Register & 3) * 8));
                break;
 



Home | Main Index | Thread Index | Old Index