From 0150f95a57641dd975c56ef8192c2cfb31eb4a6f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 1 Nov 2018 15:59:23 +0200 Subject: unit/test-sdp: Add robustness test for continuation state This adds a test for invalid continuation state: /TP/SERVER/SA/ROB/BI-01-C - init /TP/SERVER/SA/ROB/BI-01-C - setup /TP/SERVER/SA/ROB/BI-01-C - setup complete /TP/SERVER/SA/ROB/BI-01-C - run test-sdp: < 02 00 01 00 16 35 11 1c 00 00 01 00 00 00 10 00 .....5.......... test-sdp: 80 00 00 80 5f 9b 34 fb 00 01 00 ...._.4.... bluetoothd[26193]: process_request: Got a svc srch req bluetoothd[26193]: extract_des: Seq type : 53 bluetoothd[26193]: extract_des: Data size : 17 bluetoothd[26193]: extract_des: Data type: 0x1c bluetoothd[26193]: extract_des: No of elements : 1 bluetoothd[26193]: service_search_req: Expected count: 1 bluetoothd[26193]: service_search_req: Bytes scanned : 19 bluetoothd[26193]: sdp_cstate_get: Continuation State size : 0 bluetoothd[26193]: service_search_req: Checking svcRec : 0x0 bluetoothd[26193]: service_search_req: Checking svcRec : 0x1 bluetoothd[26193]: service_search_req: Checking svcRec : 0x10000 bluetoothd[26193]: service_search_req: Match count: 1 bluetoothd[26193]: process_request: Sending rsp. status 0 bluetoothd[26193]: process_request: Bytes Sent : 14 test-sdp: > 03 00 01 00 09 00 01 00 01 00 01 00 00 00 .............. test-sdp: < 04 00 01 00 0f 00 01 00 00 00 07 35 06 09 00 00 ...........5.... test-sdp: 09 00 01 00 .... bluetoothd[26193]: process_request: Got a svc attr req bluetoothd[26193]: extract_des: Seq type : 53 bluetoothd[26193]: extract_des: Data size : 6 bluetoothd[26193]: extract_des: Data type: 0x09 bluetoothd[26193]: extract_des: No of elements : 1 bluetoothd[26193]: extract_des: Data type: 0x09 bluetoothd[26193]: extract_des: No of elements : 2 bluetoothd[26193]: sdp_cstate_get: Continuation State size : 0 bluetoothd[26193]: service_attr_req: SvcRecHandle : 0x10000 bluetoothd[26193]: service_attr_req: max_rsp_size : 7 bluetoothd[26193]: extract_attrs: Entries in attr seq : 2 bluetoothd[26193]: extract_attrs: AttrDataType : 9 bluetoothd[26193]: extract_attrs: AttrDataType : 9 bluetoothd[26193]: service_attr_req: Creating continuation state of size : 18 bluetoothd[26193]: sdp_set_cstate_pdu: Non null sdp_cstate_t id : 0x5bdb0511 bluetoothd[26193]: process_request: Sending rsp. status 0 bluetoothd[26193]: process_request: Bytes Sent : 23 test-sdp: > 05 00 01 00 12 00 07 35 10 09 00 00 0a 00 08 11 .......5........ test-sdp: 05 db 5b 07 00 00 00 ..[.... test-sdp: < 04 00 02 00 17 00 01 00 00 00 07 35 06 09 00 00 ...........5.... test-sdp: 09 00 01 08 11 05 db 5b ff ff 00 00 .......[.... bluetoothd[26193]: process_request: Got a svc attr req bluetoothd[26193]: extract_des: Seq type : 53 bluetoothd[26193]: extract_des: Data size : 6 bluetoothd[26193]: extract_des: Data type: 0x09 bluetoothd[26193]: extract_des: No of elements : 1 bluetoothd[26193]: extract_des: Data type: 0x09 bluetoothd[26193]: extract_des: No of elements : 2 bluetoothd[26193]: sdp_cstate_get: Continuation State size : 8 bluetoothd[26193]: sdp_cstate_get: Cstate TS : 0x5bdb0511 bluetoothd[26193]: sdp_cstate_get: Bytes sent : 65535 bluetoothd[26193]: service_attr_req: SvcRecHandle : 0x10000 bluetoothd[26193]: service_attr_req: max_rsp_size : 7 bluetoothd[26193]: NULL cache buffer and non-NULL continuation state bluetoothd[26193]: process_request: Sending rsp. status 5 bluetoothd[26193]: process_request: Bytes Sent : 7 test-sdp: > 01 00 02 00 02 00 05 ....... /TP/SERVER/SA/ROB/BI-01-C - test passed /TP/SERVER/SA/ROB/BI-01-C - teardown /TP/SERVER/SA/ROB/BI-01-C - teardown complete /TP/SERVER/SA/ROB/BI-01-C - done --- unit/test-sdp.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'unit') diff --git a/unit/test-sdp.c b/unit/test-sdp.c index b67a55189..5a50cbbf1 100644 --- a/unit/test-sdp.c +++ b/unit/test-sdp.c @@ -45,7 +45,7 @@ struct sdp_pdu { bool valid; const void *raw_data; size_t raw_size; - uint8_t cont_len; + uint16_t cont_len; }; struct test_data { @@ -86,6 +86,7 @@ struct test_data { #define define_sa(name, args...) define_test("/TP/SERVER/SA/" name, 48, args) #define define_ssa(name, args...) define_test("/TP/SERVER/SSA/" name, 48, args) #define define_brw(name, args...) define_test("/TP/SERVER/BRW/" name, 672, args) +#define define_rob(name, args...) define_test("/TP/SERVER/ROB/" name, 48, args) /* SDP Data Element (DE) tests */ struct test_data_de { @@ -202,9 +203,13 @@ static gboolean send_pdu(gpointer user_data) memcpy(buf, req_pdu->raw_data, req_pdu->raw_size); - if (context->cont_size > 0) + if (context->cont_size > 0) { memcpy(buf + req_pdu->raw_size, context->cont_data, - context->cont_size); + context->cont_size); + if (context->cont_size != req_pdu->cont_len) + put_be16(req_pdu->cont_len, + buf + req_pdu->raw_size + 4); + } len = write(context->fd, buf, pdu_len); @@ -2803,5 +2808,28 @@ int main(int argc, char *argv[]) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00))); + /* + * Service Attribute Request + * + * Verify the correct behaviour of the IUT when searching + * for existing Attribute, using invalid continuation state. + */ + define_rob("BI-01-C", + raw_pdu(0x02, 0x00, 0x01, 0x00, 0x16, 0x35, 0x11, 0x1c, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb, + 0x00, 0x01, 0x00), + raw_pdu(0x03, 0x00, 0x01, 0x00, 0x09, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x00, 0x00), + raw_pdu(0x04, 0x00, 0x01, 0x00, 0x0f, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x07, 0x35, 0x06, 0x09, 0x00, 0x00, + 0x09, 0x00, 0x01, 0x00), + raw_pdu_cont(8, 0x05, 0x00, 0x01, 0x00, 0x12, 0x00, 0x07, 0x35, + 0x10, 0x09, 0x00, 0x00, 0x0a, 0x00, 0x08), + raw_pdu_cont(0xffff, 0x04, 0x00, 0x02, 0x00, 0x17, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x07, 0x35, 0x06, 0x09, 0x00, + 0x00, 0x09, 0x00, 0x01, 0x08), + raw_pdu(0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x05)); + return tester_run(); } -- cgit v1.2.1