Commit Graph

372 Commits

Author SHA1 Message Date
Marcel Holtmann
ea0fa83ebf lib: Add define for mgmt_set_static_address 2013-10-02 06:15:52 -07:00
Anderson Lizardo
fd8d0713e8 lib: Fix invalid "whitespace" on company identifier string
Somehow, the invalid multibyte sequence "\xC2\xA0" (which is displayed
as a whitespace) was inserted on a company identifier string. Fix this
to avoid a bogus diff when running tools/update_compids.sh.
2013-10-02 14:09:01 +03:00
Johan Hedberg
7c6c6e179a lib: Add define for mgmt_set_bredr 2013-10-02 12:16:57 +03:00
Szymon Janc
cf8a492dfd lib: Fix use of uninitialized variable in sdp_set_profile_descs
Error path on default case was not breaking loop. To keep error
handling similar all error path were converted to use goto.

This fix following:
target  C: libbluetooth <= external/bluetooth/bluez/android/../lib/sdp.c
lib/sdp.c: In function 'sdp_set_profile_descs':
lib/sdp.c:487:10: warning: 'values[0]' may be used uninitialized in
    this function [-Wmaybe-uninitialized]
lib/sdp.c:2562:19: note: 'values[0]' was declared here
lib/sdp.c:545:11: warning: 'dtds[0]' may be used uninitialized in this
    function [-Wmaybe-uninitialized]
lib/sdp.c:2562:9: note: 'dtds[0]' was declared here
2013-09-30 21:16:41 +03:00
Marcel Holtmann
24d9643a10 lib: Update company identifiers 2013-09-28 00:05:50 -07:00
Johan Hedberg
8c77159a72 mgmt: Add defines for new advertising setting 2013-09-25 13:51:11 +03:00
Marcel Holtmann
3719c6d257 lib: Update company identifiers 2013-09-21 11:40:31 -07:00
Marcel Holtmann
c0b7506c42 lib: Add definition for HCI_CHANNEL_USER 2013-09-02 11:17:05 -07:00
Marcel Holtmann
a24e0a151f lib: Update company identifiers 2013-08-07 12:21:46 -07:00
Frédéric Dalleau
c594291320 lib: SCO voice setting support header
Modify headers to enable support for changing SCO voice setting.
Corresponding commit implements functionality on kernel side.
2013-08-01 12:32:11 +03:00
Anderson Lizardo
9b686b14f2 lib: Remove duplicated HSP_HS_UUID definition
There is an identical definition on the same header file (next to
HSP_AG_UUID).
2013-07-18 12:33:08 +03:00
Szymon Janc
a727297039 lib: Add range check for SDP_SVC_ATTR_RSP/SDP_SVC_SEARCH_ATTR_RSP
This is an improved version of recently reverted commit 1796f00e84.
Response size is verified against minimal allowed value only if it is
complete response. If response is partial it is allowed by spec that
it will be split in arbitrary manner.

Verified against Nokia BH217 on which original commit caused
regression.
2013-07-10 12:36:34 +03:00
Johan Hedberg
c71e098d2e lib: Update company identifiers 2013-06-26 14:30:11 +03:00
Johan Hedberg
550dab5ce2 Revert "lib: Add range check for SDP_SVC_ATTR_RSP/SDP_SVC_SEARCH_ATTR_RSP"
This reverts commit 1796f00e84.

This patch causes a regression with the Nokia BH217 headset. A correct
patch must take into account fragmented responses.
2013-06-25 21:44:17 +03:00
Szymon Janc
d82a3f679e lib: Cleanup SDP logs to not include double new lines
SDPERR and SDPDBG already add new line to prints.
2013-06-24 11:08:03 +03:00
Alex Deymo
0585258ea1 lib: Fix two size constants
Fixes the value of RESET_FAILED_CONTACT_COUNTER_RP_SIZE and
RESET_FAILED_CONTACT_COUNTER_RP_SIZE macros to respect the
associated struct.
2013-06-16 18:25:46 +03:00
Johan Hedberg
4f8952b201 mgmt: Add support for new MGMT_STATUS_RFKILLED 2013-05-29 09:49:21 +03:00
Luiz Augusto von Dentz
7913d91635 lib: Fix sdp_seq_alloc_with_length accessing invalid index/memory
The sequence itself is not an index of dtds, values, lengths, thats why
SDP_SEQ8 is used directly as dtd, so accessing length[i] is always off
by one.

Furthermore the length is not really used by sdp_data_alloc_with_length
when the dtd is SDP_SEQ8 which is probably why it doesn't crash.
2013-05-23 14:57:09 -07:00
Johan Hedberg
3b60c35aba lib: Update company identifiers 2013-05-19 07:08:31 +03:00
Anderson Lizardo
cc11bc19c2 lib: Fix list of company identifiers
Fix minor typos on company names.
2013-04-30 13:16:12 +03:00
Christian Fetzer
41d61ddc98 lib: Add attributes MASInstanceID and SupportedMessageTypes 2013-04-17 13:43:45 +03:00
Marcel Holtmann
eb1f591c79 lib: Update list of company identifiers 2013-04-10 22:23:49 -07:00
Arkadiusz Lichwa
e63b0f9035 lib: Fix invalid memory access in sdp_service_search_attr_req
Browsing services using sdptool can lead to writing to invalid heap
locations.

valgrind's output of exemplary call: sdptool browse local

==2203== HEAP SUMMARY:
==2203==     in use at exit: 0 bytes in 0 blocks
==2203==   total heap usage: 251 allocs, 251 frees, 140,156 bytes allocated
==2203==
==2203== All heap blocks were freed -- no leaks are possible
==2203==
==2203== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0)
==2203==
==2203== 1 errors in context 1 of 2:
==2203== Invalid write of size 2
==2203==    at 0x805B882: bt_put_be16 (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8062BD0: sdp_service_search_attr_req (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8052457: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x80525AE: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x805277F: cmd_browse (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8053199: main (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==  Address 0x4391359 is 7 bytes before a block of size 2,048 alloc'd
==2203==    at 0x402B6A8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2203==    by 0x8062B4B: sdp_service_search_attr_req (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8052457: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x80525AE: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x805277F: cmd_browse (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8053199: main (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==
==2203==
==2203== 5 errors in context 2 of 2:
==2203== Invalid write of size 1
==2203==    at 0x402D363: memcpy (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2203==    by 0x80613E7: gen_dataseq_pdu (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8061472: gen_attridseq_pdu (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8062C00: sdp_service_search_attr_req (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8052457: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x80525AE: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x805277F: cmd_browse (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8053199: main (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==  Address 0x439135b is 5 bytes before a block of size 2,048 alloc'd
==2203==    at 0x402B6A8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2203==    by 0x8062B4B: sdp_service_search_attr_req (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8052457: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x80525AE: do_search (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x805277F: cmd_browse (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==    by 0x8053199: main (in /home/xpu/gits/bluez.bin/bin/sdptool)
==2203==
==2203== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0)
2013-04-04 15:35:50 +03:00
Marcel Holtmann
d3a95e3088 lib: Update list of company identifiers 2013-03-21 11:48:13 -07:00
Marcel Holtmann
786f0e0e33 lib: Update list of company identifiers 2013-02-23 12:00:03 +01:00
Anderson Lizardo
b52d10d7ab lib: Validate DTDs when parsing VersionNumberList 2013-02-18 10:01:27 +02:00
Anderson Lizardo
4c07609a59 lib: Add comment to BluetoothProfileDescriptorList parsing workaround
Commits 0f5a5a9580 and
46b3a3d2d0 introduced this workaround.
2013-02-18 10:01:23 +02:00
Anderson Lizardo
bbabc6792c lib: Validate DTDs when parsing BluetoothProfileDescriptorList
The "seq->val.dataseq != NULL" check is also removed from the for()
statement because it should be done after verifying that the data
element is a sequence (inside the "if (SDP_IS_SEQ(...))" block.)
2013-02-18 10:01:06 +02:00
Anderson Lizardo
1e75de470e lib: Validate DTDs when parsing LanguageBaseAttributeIDList
Also check if the required number of entries is present.
2013-02-18 10:00:52 +02:00
Anderson Lizardo
67c7f0bf9b lib: Add missing DTD validation in sdp_record_print() 2013-02-18 10:00:33 +02:00
Anderson Lizardo
fcb9ece0f9 lib: Fix missing DTD validation while accessing SDP data elements
It is necessary to validate the sdp_data_t "dtd" field before accessing
the "val" union members, specially when handling SDP_SEQ*, SDP_ALT* and
SDP_STR* elements, otherwise remote devices can trigger memory
corruption by passing invalid data elements where others are expected.
2013-02-18 09:59:35 +02:00
Anderson Lizardo
9e2d91bc75 lib: Add SDP_IS_ALT() macro
This macro will simplify internal SDP library code, and is similar to
the existing SDP_IS_SEQ() macro.
2013-02-18 09:59:35 +02:00
Anderson Lizardo
5e72074c9c lib: Cleanup coding style in sdp_get_proto_descs() 2013-02-18 09:59:35 +02:00
Anderson Lizardo
eff66b3ebb lib: Reuse identical code in sdp_get_{add,}_access_protos()
sdp_get_access_protos() and sdp_get_add_access_protos() do almost
exactly the same thing, except for an additional statement for the
latter.
2013-02-18 09:59:34 +02:00
Anderson Lizardo
6cf4291ff3 lib: Check if SDP buffer has enough data on partial responses
Before manipulating data from previous partial responses, make sure the
buffer has enough data.
2013-02-15 12:38:41 +02:00
Anderson Lizardo
1796f00e84 lib: Add range check for SDP_SVC_ATTR_RSP/SDP_SVC_SEARCH_ATTR_RSP
According to SDP spec, the byte count fields for these PDUs have a valid
range of 0x0002-0xFFFF.
2013-02-15 12:37:03 +02:00
Anderson Lizardo
870fe03a79 lib: Fix buffer overflow when processing SDP response
rsp_count is either read or calculated from untrusted input, and
therefore needs to be checked before being used as offset. The "plen"
variable is appropriate because it is calculated as the sum of fixed and
variable length fields, excluding the continuation state field, which
has at least 1 byte for its own length field.
2013-02-15 12:36:42 +02:00
Marcel Holtmann
022756d28e lib: Update list of company identifiers 2013-02-02 01:19:29 +01:00
Marcel Holtmann
19c71d2945 lib: Update list of company identifiers 2013-01-13 15:17:53 -08:00
Marcel Holtmann
6861b49c18 lib: Remove all management settings helpers since they are unused now 2013-01-09 19:44:00 -08:00
Marcel Holtmann
454e1deea8 lib: Remove current unused management settings helpers 2013-01-09 19:13:07 -08:00
Anderson Lizardo
504a0cf46a lib: Fix SDP_TEXT_STR16/SDP_URL_STR16 parsing
sdp_extract_attr() uses the "size" parameter to return the number of
bytes consumed when parsing SDP Data Elements. This size is used to
advance a buffer pointer to parse next element.

This size was being incorrectly calculated for SDP_{TEXT,URL}_STR16 in
extract_str(), where the string length was added twice. The string
length is already added later in the function for {TEXT,URL}_STR{8,16}
by this statement:

*len += n;
2013-01-08 18:24:53 -08:00
Anderson Lizardo
31eac66521 lib: Use SDP_IS_TEXT_STR()/SDP_IS_SEQ() where possible 2013-01-07 14:16:45 +02:00
Anderson Lizardo
5ba183dc82 lib: Trivial whitespace and line wrapping fix 2013-01-07 14:16:34 +02:00
Anderson Lizardo
0305cfa11a lib: Add SDP_IS_TEXT_STR() macro for SDP_TEXT_STR* checking
This new macro avoids constructs like "if (d->dtd < SDP_TEXT_STR8 ||
d->dtd > SDP_TEXT_STR32)" which are harder to read.
2013-01-07 14:16:24 +02:00
Johan Hedberg
7facee2446 core: Move mgmt setting convenience macros to lib/mgmt.h 2013-01-03 15:44:51 +02:00
Marcel Holtmann
224473bc9f lib: Avoid using HCI_MAX_NAME_LENGTH in management header 2012-12-31 17:09:52 -08:00
Marcel Holtmann
7003e67273 lib: Make bt_compidtostr return value const 2012-12-29 22:58:11 -08:00
Marcel Holtmann
e6f9affe72 lib: Update company names to match latest release 2012-12-27 23:40:05 -08:00
Cristian Rodríguez
741b85b8f8 lib: Use SOCK_CLOEXEC where needed
Calling programs might fork().. execve() and we will end
up leaking fds.
2012-12-24 09:13:59 -08:00