Commit Graph

353 Commits

Author SHA1 Message Date
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
Cristian Rodríguez
3a278bb062 lib: use %m instead of strerror
Unlike strerror, %m is thread safe and we do not know
to what kind of program libbluetooth is being linked too.
2012-12-24 09:07:03 -08:00
Marcel Holtmann
85730891d9 lib: Update company identifiers 2012-12-22 19:43:14 -08:00
Marcel Holtmann
55bf340c04 build: Move bluez.pc into the library directory 2012-12-19 18:27:14 +01:00
Marcel Holtmann
b6442a63bd lib: Correct AMP assoc data structures 2012-12-17 23:42:29 +01:00
Marcel Holtmann
d54a7fe75a lib: Add definition for Num Completed Data Blocks event 2012-12-17 23:36:17 +01:00
Marcel Holtmann
0ab93149e0 lib: Add definition for Read Data Block Size HCI command 2012-12-17 23:34:34 +01:00
Szymon Janc
28cf717c04 sdp: Fix build errors due to unaligned memory access
This fix following compilation errors on ARM.

  CC     lib/sdp.lo
lib/sdp.c: In function 'sdp_device_record_unregister_binary':
lib/sdp.c:2984:11: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c:2984:11: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c: In function 'sdp_device_record_update':
lib/sdp.c:3089:11: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c:3089:11: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c: In function 'sdp_process':
lib/sdp.c:4139:22: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c:4146:14: error: cast increases required alignment of
	target type [-Werror=cast-align]
lib/sdp.c:4146:14: error: cast increases required alignment of
	target type [-Werror=cast-align]
cc1: all warnings being treated as errors
make[1]: *** [lib/sdp.lo] Error 1
2012-12-11 07:41:07 +02:00
Johan Hedberg
b8779d2202 Revert "Ensure config.h is included by using CPPFLAGS"
This reverts commit 8a03376544.

The patch needs to be split up and the gdbus/ changes were bogus
compared to the original commit message.

Conflicts:
	Makefile.am
	Makefile.obexd
	profiles/cyclingspeed/cyclingspeed.c
	profiles/heartrate/heartrate.c
	src/error.c
2012-12-07 12:46:04 +02:00
Anderson Lizardo
8f0d6c96c4 lib: Fix member type on le_read_advertising_channel_tx_power_rp
Transmit power level range is -20 <= N <= 10, thus it should be stored
as int8_t.
2012-12-06 12:24:04 +02:00
Lucas De Marchi
8a03376544 Ensure config.h is included by using CPPFLAGS
Instead of trying to include config.h in each file over the tree and
possibly forgetting to include it, give a "-include config.h" argument
to the compiler so it's guaranteed that a) it will be included for all
source files and b) it will be the first header included.

gdbus/ directory is left out, since it would break other projects using
it.
2012-12-05 17:18:07 +02:00
Andrzej Kaczmarek
727fddeb96 cyclingspeed: Discover CSCS characteristics 2012-12-05 10:11:23 +02:00
Andrzej Kaczmarek
941c44472a cyclingspeed: Add CSC profile plugin skeleton
This patch adds stub profile driver plugin for CSC profile.
2012-12-05 10:08:43 +02:00
Johan Hedberg
8ac20a715c lib: Add missing svclass entries for MAP 2012-11-23 14:33:49 +02:00
Bart Westgeest
f8b977a776 sdp: Upgrade datatype SEQ8 to SEQ16 when data size is greater than 256
Fixes a bug where the complete sequence data is written, but the size
is truncated to one byte.
2012-11-20 14:53:21 +02:00
Bart Westgeest
06c25421af sdp: Limit side effects of sdp_get_data_type and sdp_get_data_size
Remove modification of buf->buf_size in 'get' functions. Data is
still indirectly modified due to recursive nature of code.

Renamed sdp_get_data_type to sdp_get_data_type_size.
2012-11-20 14:52:34 +02:00
Bart Westgeest
74116be7b8 sdp: Inlined single use of function sdp_set_data_type
Inlining single use of sdp_set_data_type to improve code readability,
since the function was doing more than just setting the data type.
2012-11-20 14:51:16 +02:00
Johan Hedberg
356386cd2f core: Add Service property for external profiles
This property is used to distinguish the service class UUID from the
actual profile UUID.
2012-11-16 14:27:51 +02:00
Johan Hedberg
b1c4a376bf lib: Add new Network attribute define for HFP 1.6 AG record 2012-11-15 12:46:10 +02:00
Johan Hedberg
0eff937073 lib: Add missing OBEX UUID strings to uuid.h 2012-11-14 14:50:05 +02:00