Source-Changes-HG archive

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

[src/trunk]: src Don't crash when the device's HID Report Descriptor Pops fro...



details:   https://anonhg.NetBSD.org/src/rev/66dacb9384e3
branches:  trunk
changeset: 342748:66dacb9384e3
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Thu Jan 07 16:10:49 2016 +0000

description:
Don't crash when the device's HID Report Descriptor Pops from an empty stack.

diffstat:

 lib/libusbhid/parse.c          |  6 ++++--
 sys/dev/usb/hid.c              |  6 ++++--
 tests/dev/usb/t_hid.c          |  6 ++----
 tests/lib/libusbhid/t_usbhid.c |  6 ++----
 4 files changed, 12 insertions(+), 12 deletions(-)

diffs (108 lines):

diff -r 90a54f668445 -r 66dacb9384e3 lib/libusbhid/parse.c
--- a/lib/libusbhid/parse.c     Thu Jan 07 15:58:23 2016 +0000
+++ b/lib/libusbhid/parse.c     Thu Jan 07 16:10:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.8 2011/05/23 15:16:27 joerg Exp $  */
+/*     $NetBSD: parse.c,v 1.9 2016/01/07 16:10:49 jakllsch Exp $       */
 
 /*
  * Copyright (c) 1999, 2001 Lennart Augustsson <augustss%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.8 2011/05/23 15:16:27 joerg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.9 2016/01/07 16:10:49 jakllsch Exp $");
 
 #include <assert.h>
 #include <stdlib.h>
@@ -375,6 +375,8 @@
                                break;
                        case 11: /* Pop */
                                hi = c->next;
+                               if (hi == NULL)
+                                       break;
                                s->cur = *hi;
                                free(hi);
                                break;
diff -r 90a54f668445 -r 66dacb9384e3 sys/dev/usb/hid.c
--- a/sys/dev/usb/hid.c Thu Jan 07 15:58:23 2016 +0000
+++ b/sys/dev/usb/hid.c Thu Jan 07 16:10:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hid.c,v 1.39 2016/01/02 20:57:10 jakllsch Exp $        */
+/*     $NetBSD: hid.c,v 1.40 2016/01/07 16:10:49 jakllsch Exp $        */
 /*     $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.39 2016/01/02 20:57:10 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.40 2016/01/07 16:10:49 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -298,6 +298,8 @@
                                break;
                        case 11: /* Pop */
                                hi = c->next;
+                               if (hi == NULL)
+                                       break;
                                oldpos = c->loc.pos;
                                *c = *hi;
                                c->loc.pos = oldpos;
diff -r 90a54f668445 -r 66dacb9384e3 tests/dev/usb/t_hid.c
--- a/tests/dev/usb/t_hid.c     Thu Jan 07 15:58:23 2016 +0000
+++ b/tests/dev/usb/t_hid.c     Thu Jan 07 16:10:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_hid.c,v 1.2 2016/01/07 15:58:23 jakllsch Exp $       */
+/*     $NetBSD: t_hid.c,v 1.3 2016/01/07 16:10:49 jakllsch Exp $       */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_hid.c,v 1.2 2016/01/07 15:58:23 jakllsch Exp $");
+__RCSID("$NetBSD: t_hid.c,v 1.3 2016/01/07 16:10:49 jakllsch Exp $");
 
 #include <machine/types.h>
 #include <stdlib.h>
@@ -214,8 +214,6 @@
        struct hid_data *hdp;
        struct hid_item hi;
 
-       atf_tc_expect_fail("Pop crashes on empty stack.");
-
        hdp = hid_start_parse(just_pop_report_descriptor,
            sizeof just_pop_report_descriptor, hid_none);
        while (hid_get_item(hdp, &hi) > 0) {
diff -r 90a54f668445 -r 66dacb9384e3 tests/lib/libusbhid/t_usbhid.c
--- a/tests/lib/libusbhid/t_usbhid.c    Thu Jan 07 15:58:23 2016 +0000
+++ b/tests/lib/libusbhid/t_usbhid.c    Thu Jan 07 16:10:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_usbhid.c,v 1.10 2016/01/07 15:58:23 jakllsch Exp $   */
+/*     $NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $   */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_usbhid.c,v 1.10 2016/01/07 15:58:23 jakllsch Exp $");
+__RCSID("$NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $");
 
 #include <atf-c.h>
 
@@ -424,8 +424,6 @@
        hid_data_t hd;
        hid_item_t hi;
 
-       atf_tc_expect_fail("segfaults");
-
        ATF_REQUIRE((hrd = hid_use_report_desc(
            just_pop_report_descriptor,
            sizeof just_pop_report_descriptor)) != NULL);



Home | Main Index | Thread Index | Old Index