Module Name:    src
Committed By:   bouyer
Date:           Sun Dec  3 17:34:51 UTC 2017

Modified Files:
        src/sys/dev/acpi/wmi: wmi_acpi.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/acpi/wmi/wmi_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/wmi/wmi_acpi.c
diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.15 src/sys/dev/acpi/wmi/wmi_acpi.c:1.16
--- src/sys/dev/acpi/wmi/wmi_acpi.c:1.15	Thu Jun  1 02:45:09 2017
+++ src/sys/dev/acpi/wmi/wmi_acpi.c	Sun Dec  3 17:34:50 2017
@@ -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 <[email protected]>
@@ -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 @@ acpi_wmi_guid_get(struct acpi_wmi_softc 
 	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 @@ acpi_wmi_guid_get(struct acpi_wmi_softc 
 			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 @@ acpi_wmi_enable_collection(ACPI_HANDLE h
 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)

Reply via email to