Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests Add tests for HID Parser Pop-on-empty-stack bug.
details: https://anonhg.NetBSD.org/src/rev/90a54f668445
branches: trunk
changeset: 342747:90a54f668445
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Thu Jan 07 15:58:23 2016 +0000
description:
Add tests for HID Parser Pop-on-empty-stack bug.
diffstat:
tests/dev/usb/t_hid.c | 28 ++++++++++++++++++++++++++--
tests/lib/libusbhid/hid_test_data.c | 5 ++++-
tests/lib/libusbhid/t_usbhid.c | 31 +++++++++++++++++++++++++++++--
3 files changed, 59 insertions(+), 5 deletions(-)
diffs (135 lines):
diff -r c47bf27aa25f -r 90a54f668445 tests/dev/usb/t_hid.c
--- a/tests/dev/usb/t_hid.c Thu Jan 07 14:15:26 2016 +0000
+++ b/tests/dev/usb/t_hid.c Thu Jan 07 15:58:23 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_hid.c,v 1.1 2016/01/05 17:22:38 jakllsch Exp $ */
+/* $NetBSD: t_hid.c,v 1.2 2016/01/07 15:58:23 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_hid.c,v 1.1 2016/01/05 17:22:38 jakllsch Exp $");
+__RCSID("$NetBSD: t_hid.c,v 1.2 2016/01/07 15:58:23 jakllsch Exp $");
#include <machine/types.h>
#include <stdlib.h>
@@ -200,10 +200,34 @@
&hi.loc), 0xff);
}
+ATF_TC(khid_parse_just_pop);
+
+ATF_TC_HEAD(khid_parse_just_pop, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "check kernel hid.c for "
+ "Pop on empty stack bug");
+}
+
+ATF_TC_BODY(khid_parse_just_pop, tc)
+{
+ 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) {
+ }
+ hid_end_parse(hdp);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, khid);
+ ATF_TP_ADD_TC(tp, khid_parse_just_pop);
return atf_no_error();
}
diff -r c47bf27aa25f -r 90a54f668445 tests/lib/libusbhid/hid_test_data.c
--- a/tests/lib/libusbhid/hid_test_data.c Thu Jan 07 14:15:26 2016 +0000
+++ b/tests/lib/libusbhid/hid_test_data.c Thu Jan 07 15:58:23 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hid_test_data.c,v 1.1 2016/01/04 22:07:16 jakllsch Exp $ */
+/* $NetBSD: hid_test_data.c,v 1.2 2016/01/07 15:58:23 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -132,3 +132,6 @@
0xff,
};
+static const uint8_t just_pop_report_descriptor[] = {
+ 0xb4,
+};
diff -r c47bf27aa25f -r 90a54f668445 tests/lib/libusbhid/t_usbhid.c
--- a/tests/lib/libusbhid/t_usbhid.c Thu Jan 07 14:15:26 2016 +0000
+++ b/tests/lib/libusbhid/t_usbhid.c Thu Jan 07 15:58:23 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_usbhid.c,v 1.9 2016/01/04 22:07:16 jakllsch Exp $ */
+/* $NetBSD: t_usbhid.c,v 1.10 2016/01/07 15:58:23 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_usbhid.c,v 1.9 2016/01/04 22:07:16 jakllsch Exp $");
+__RCSID("$NetBSD: t_usbhid.c,v 1.10 2016/01/07 15:58:23 jakllsch Exp $");
#include <atf-c.h>
@@ -45,6 +45,7 @@
ATF_TC(check_hid_usage);
ATF_TC(check_hid_get_data);
ATF_TC(check_hid_set_data);
+ATF_TC(check_parse_just_pop);
#define MYd_ATF_CHECK_EQ(d, v) \
ATF_CHECK_EQ_MSG(d, v, "== %d", (d))
@@ -411,6 +412,31 @@
hrd = NULL;
}
+ATF_TC_HEAD(check_parse_just_pop, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "check Pop on empty stack bug");
+}
+
+ATF_TC_BODY(check_parse_just_pop, tc)
+{
+ report_desc_t hrd;
+ 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);
+ hd = hid_start_parse(hrd, 0, NO_REPORT_ID);
+ while (hid_get_item(hd, &hi) > 0) {
+ }
+ hid_end_parse(hd);
+ hid_dispose_report_desc(hrd);
+ hrd = NULL;
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -419,6 +445,7 @@
ATF_TP_ADD_TC(tp, check_hid_usage);
ATF_TP_ADD_TC(tp, check_hid_get_data);
ATF_TP_ADD_TC(tp, check_hid_set_data);
+ ATF_TP_ADD_TC(tp, check_parse_just_pop);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index