linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/tester: Add Device Found test with invalid field length
@ 2015-09-14 20:03 Szymon Janc
  2015-09-16 18:08 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2015-09-14 20:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This test verify if kernel correctly terminates EIR when invalid
advertising data (field length too big) was received from
remote device.
---
 tools/mgmt-tester.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 9ace20a..0a1a7c2 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4707,6 +4707,30 @@ static const struct generic_data device_found_gtag = {
 	.adv_data = adv_data_invalid_significant_len,
 };
 
+static const uint8_t adv_data_invalid_field_len[] = { 0x02, 0x01, 0x01,
+		0x05, 0x09, 0x74, 0x65, 0x73, 0x74,
+		0xa0, 0xff, 0x01, 0x02, 0x03, 0x04, 0x05};
+
+static const char device_found_valid2[] = { 0x00, 0x00, 0x01, 0x01, 0xaa, 0x00,
+		0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x02, 0x01,
+		0x01, 0x05, 0x09, 0x74, 0x65, 0x73, 0x74};
+
+static const struct generic_data device_found_invalid_field = {
+	.setup_settings = settings_powered_le,
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_le_param,
+	.send_len = sizeof(start_discovery_le_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_le_param,
+	.expect_len = sizeof(start_discovery_le_param),
+	.expect_alt_ev = MGMT_EV_DEVICE_FOUND,
+	.expect_alt_ev_param = device_found_valid2,
+	.expect_alt_ev_len = sizeof(device_found_valid2),
+	.set_adv = true,
+	.adv_data_len = sizeof(adv_data_invalid_field_len),
+	.adv_data = adv_data_invalid_field_len,
+};
+
 static const struct generic_data read_local_oob_not_powered_test = {
 	.send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA,
 	.expect_status = MGMT_STATUS_NOT_POWERED,
@@ -6957,9 +6981,12 @@ int main(int argc, char *argv[])
 				&read_local_oob_success_sc_test,
 				NULL, test_command_generic);
 
-	test_bredrle("Device Found - Invalid remote ADV_DATA",
+	test_bredrle("Device Found - Advertising data - Zero padded",
 				&device_found_gtag,
 				NULL, test_device_found);
+	test_bredrle("Device Found - Advertising data - Invalid field",
+				&device_found_invalid_field,
+				NULL, test_device_found);
 
 	return tester_run();
 }
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/tester: Add Device Found test with invalid field length
  2015-09-14 20:03 [PATCH] tools/tester: Add Device Found test with invalid field length Szymon Janc
@ 2015-09-16 18:08 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2015-09-16 18:08 UTC (permalink / raw)
  To: linux-bluetooth

On Monday 14 September 2015 22:03:16 Szymon Janc wrote:
> This test verify if kernel correctly terminates EIR when invalid
> advertising data (field length too big) was received from
> remote device.
> ---
>  tools/mgmt-tester.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
> index 9ace20a..0a1a7c2 100644
> --- a/tools/mgmt-tester.c
> +++ b/tools/mgmt-tester.c
> @@ -4707,6 +4707,30 @@ static const struct generic_data device_found_gtag =
> { .adv_data = adv_data_invalid_significant_len,
>  };
> 
> +static const uint8_t adv_data_invalid_field_len[] = { 0x02, 0x01, 0x01,
> +		0x05, 0x09, 0x74, 0x65, 0x73, 0x74,
> +		0xa0, 0xff, 0x01, 0x02, 0x03, 0x04, 0x05};
> +
> +static const char device_found_valid2[] = { 0x00, 0x00, 0x01, 0x01, 0xaa,
> 0x00, +		0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x02, 0x01,
> +		0x01, 0x05, 0x09, 0x74, 0x65, 0x73, 0x74};
> +
> +static const struct generic_data device_found_invalid_field = {
> +	.setup_settings = settings_powered_le,
> +	.send_opcode = MGMT_OP_START_DISCOVERY,
> +	.send_param = start_discovery_le_param,
> +	.send_len = sizeof(start_discovery_le_param),
> +	.expect_status = MGMT_STATUS_SUCCESS,
> +	.expect_param = start_discovery_le_param,
> +	.expect_len = sizeof(start_discovery_le_param),
> +	.expect_alt_ev = MGMT_EV_DEVICE_FOUND,
> +	.expect_alt_ev_param = device_found_valid2,
> +	.expect_alt_ev_len = sizeof(device_found_valid2),
> +	.set_adv = true,
> +	.adv_data_len = sizeof(adv_data_invalid_field_len),
> +	.adv_data = adv_data_invalid_field_len,
> +};
> +
>  static const struct generic_data read_local_oob_not_powered_test = {
>  	.send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA,
>  	.expect_status = MGMT_STATUS_NOT_POWERED,
> @@ -6957,9 +6981,12 @@ int main(int argc, char *argv[])
>  				&read_local_oob_success_sc_test,
>  				NULL, test_command_generic);
> 
> -	test_bredrle("Device Found - Invalid remote ADV_DATA",
> +	test_bredrle("Device Found - Advertising data - Zero padded",
>  				&device_found_gtag,
>  				NULL, test_device_found);
> +	test_bredrle("Device Found - Advertising data - Invalid field",
> +				&device_found_invalid_field,
> +				NULL, test_device_found);
> 
>  	return tester_run();
>  }

Applied.

-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-16 18:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14 20:03 [PATCH] tools/tester: Add Device Found test with invalid field length Szymon Janc
2015-09-16 18:08 ` Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).