Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi/wmi - make sure strtoul() is called with a NULL...



details:   https://anonhg.NetBSD.org/src/rev/e8fe4202292c
branches:  trunk
changeset: 828229:e8fe4202292c
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Dec 03 17:34:50 2017 +0000

description:
- make sure strtoul() is called with a NULL-terminated string.
- acpi_wmi_input(): a valid data block may have flags set to 0.

diffstat:

 sys/dev/acpi/wmi/wmi_acpi.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r d069c124dd22 -r e8fe4202292c sys/dev/acpi/wmi/wmi_acpi.c
--- a/sys/dev/acpi/wmi/wmi_acpi.c       Sun Dec 03 17:18:53 2017 +0000
+++ b/sys/dev/acpi/wmi/wmi_acpi.c       Sun Dec 03 17:34:50 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wmi_acpi.c,v 1.15 2017/06/01 02:45:09 chs Exp $        */
+/*     $NetBSD: wmi_acpi.c,v 1.16 2017/12/03 17:34:50 bouyer Exp $     */
 
 /*-
  * Copyright (c) 2009, 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.15 2017/06/01 02:45:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.16 2017/12/03 17:34:50 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -323,7 +323,7 @@
        struct wmi_t *wmi;
        struct guid_t *guid;
        char bin[16];
-       char hex[2];
+       char hex[3];
        const char *ptr;
        uint8_t i;
 
@@ -336,6 +336,7 @@
                        ptr++;
 
                (void)memcpy(hex, ptr, 2);
+               hex[2] = '\0';
 
                if (HEXCHAR(hex[0]) == 0 || HEXCHAR(hex[1]) == 0)
                        return AE_BAD_HEX_CONSTANT;
@@ -613,8 +614,10 @@
 static bool
 acpi_wmi_input(struct wmi_t *wmi, uint8_t flag, uint8_t idx)
 {
-
-       if ((wmi->guid.flags & flag) == 0)
+       /* A data block may have no flags at all */
+       if ((wmi->guid.flags & flag) == 0 &&
+           (flag == ACPI_WMI_FLAG_DATA  &&
+            (wmi->guid.flags & ~ACPI_WMI_FLAG_EXPENSIVE) != 0))
                return false;
 
        if (wmi->guid.count == 0x00)



Home | Main Index | Thread Index | Old Index