Commit Graph

1382 Commits

Author SHA1 Message Date
ERAMOTO Masaya
53f064d5c4 obexd: Remove unused source/header files for dbus
Due to using g_dbus_emit_property_changed() and g_dbus_get_properties(),
obex_dbus_signal_property_changed() is unused since commit 96063756
("obex-client: Rename org.bluez.obex.Transfer to Transfer1"), and
OBC_PROPERTIES_ARRAY_SIGNATURE macro is unused since commit 3eadc034
("obex-client: Make use of g_dbus_get_properties to get transfer properties").
2018-03-01 10:49:05 +02:00
ERAMOTO Masaya
2bb5392474 obexd: Use g_dbus_dict_append_entry() 2018-03-01 10:49:05 +02:00
ERAMOTO Masaya
c361096818 obexd: Fix null response name
Prints out "<unknown>" string if there is no response name as below:

  obexd[8117]: obexd/src/obex.c:cmd_connect()
  obexd[8117]: CONNECT(0x0), (null)(0xffffffff)
2018-02-14 12:50:31 +02:00
ERAMOTO Masaya
bb16051518 obexd: Emit Size property of transfer after open()
Emits the Size property of transfer after calling ->open() because it
may update the size information.
2018-02-12 13:36:09 +02:00
ERAMOTO Masaya
3e9617fcd8 obexd: Use emitting function wrapped for transfer
Also replaces emit_transfer_progress() with the new wrapper function
because the total/transferred arguments have not been used since commit
a5c2b6e8 ("obexd: Align client and server spec of org.bluez.obex.Transfer1")
and g_dbus_emit_property_changed_full() checks if the path argument is
NULL.
2018-02-12 13:35:33 +02:00
Luiz Augusto von Dentz
7c85e85a65 obexd: Fix property Size of server transfer
OBJECT_SIZE_DELETE is shall not be consider a valid size.
2018-01-24 11:06:16 -02:00
ERAMOTO Masaya
4017e79914 obexd: Clean up unneeded list in src/obex.c
Cleans up the sessions list which has been unneeded by commit 8572afb4
("obexd: Make use of transport drivers and some cleanups").
2018-01-23 15:41:01 -02:00
ERAMOTO Masaya
d84bd7754b obexd: Fix crash when canceling without agent
When obexd is started with the option auto-accept or the agent is killed
after starting to transfer a file, obexd crashes due to cancellation of
the transfer from a client as below:

  Process terminating with default action of signal 11 (SIGSEGV)
   Access not within mapped region at address 0x0
     at 0x158A40: transfer_cancel (manager.c:272)
     by 0x18A5D2: process_message.isra.4 (object.c:259)
     by 0x18AE44: generic_message (object.c:1079)
     by 0x5290FD2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x5282623: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x184DBF: message_dispatch (mainloop.c:72)
     by 0x5505E24: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x55061EF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x5506501: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x137902: main (main.c:322)
2017-11-28 16:25:18 +02:00
ERAMOTO Masaya
251a2b3ca4 obexd: Fix fd which is left even after closing session
A fd is duplicated if dbus type is unix fd, and then it is not closed
even after the file is finished transporting. In the end obexd can not
transport due to the limitation of open-able fd as below.

  Warning: invalid file descriptor 1031 in syscall fcntl(DUPFD_CLOEXEC)()

  FILE DESCRIPTORS: 1021 open at exit.
  Open pf-31 socket 1023:
     at 0x5061F1F: fcntl_common (fcntl.c:46)
     by 0x5061F1F: fcntl (fcntl.c:79)
     by 0x52A1C3D: _dbus_dup (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x528C7B8: dbus_message_iter_get_basic (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x149E04: profile_new_connection (bluetooth.c:136)
     by 0x18AAF2: process_message.isra.3 (object.c:259)
     by 0x18B364: generic_message (object.c:1079)
     by 0x5290FD2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x5282623: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x1852FF: message_dispatch (mainloop.c:72)
     by 0x5505E24: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x55061EF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x5506501: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
2017-11-21 17:15:24 +02:00
Bastien Nocera
616a57f5d6 obexd: Fix compilation error on newer glibc
Since this glibc commit:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=37f802f86400684c8d13403958b2c598721d6360

glibc doesn't include declare ssize_t when fcntl.h is included (fcntl.h
included <bits/uio.h> which includes <sys/types.h>).

This fixes the following compile-time error:

In file included from obexd/plugins/mas.c:41:0:
./obexd/src/obex.h:37:1: error: unknown type name ‘ssize_t’; did you mean ‘size_t’?
 ssize_t obex_get_size(struct obex_session *os);
 ^~~~~~~
2017-11-03 13:00:57 +02:00
Luiz Augusto von Dentz
b5fbb08a56 obex: Fix always searching UUID using 128 bit format
When discovering the SDP records the code should attempt to use
16 bit format whenever possible.
2017-10-06 09:43:34 +03:00
Marcel Holtmann
1862586e8c obexd: Add missing fall through declaration 2017-07-11 11:30:55 -07:00
Syam Sidhardhan
fd3868ebc7 obexd: Fix memory leak in phonebook-dummy
g_build_filename() returns a newly-allocated string
that must be freed with g_free().
2017-07-07 10:01:42 +03:00
Matias Karhumaa
3467bb836d obexd: Fix null pointer dereference.
By sending OPP Put request before CONNECT we were able to cause
SIGSEGV in obexd. Crash was caused by null pointer dereference.
Crash was found using Synopsys Defensics Obex Server test suite.

This was fixed by calling os->service->connect if CONNECT was not
done before.
2017-06-22 14:21:17 +03:00
Sathish Narasimman
9d4658a2e3 obexd/map: msg dummy implement message listing
For messages dummy, message listing functionality in implemented in
this patch. The inputs for message listing is derived from the
mlisting.xml file that is to be present in each folder(inbox, sent,
drafts)

> ACL Data RX: Handle 256 flags 0x02 dlen 78
      Channel: 64 len 74 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x83 cr 1 dlci 0x20
         Control: 0xff poll/final 1
         Length: 69
         FCS: 0xc4
         Credits: 1
        83 00 45 cb 00 00 00 02 01 00 0d 00 73 00 65 00  ..E.........s.e.
        6e 00 74 00 00 42 00 18 78 2d 62 74 2f 4d 41 50  n.t..B..x-bt/MAP
        2d 6d 73 67 2d 6c 69 73 74 69 6e 67 00 4c 00 18  -msg-listing.L..
        01 02 00 0b 02 02 00 00 13 01 ff 06 01 00 07 00  ................
        08 00 09 01 00 c4                                ......
< ACL Data TX: Handle 256 flags 0x00 dlen 1017
      Channel: 65 len 1013 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x81 cr 0 dlci 0x20
         Control: 0xef poll/final 0
         Length: 28675
         FCS: 0x02
        90 08 63 4c 00 21 12 02 00 0b 19 15 32 30 31 37  ..cL.!......2017
        30 36 31 32 54 31 32 32 35 31 33 2d 20 35 33 30  0612T122513- 530
        00 0d 01 00 48 08 3f 3c 4d 41 50 2d 6d 73 67 2d  ....H.?<MAP-msg-
        6c 69 73 74 69 6e 67 20 76 65 72 73 69 6f 6e 3d  listing version=
        22 31 2e 30 22 3e 3c 6d 73 67 20 68 61 6e 64 6c  "1.0"><msg handl
        65 3d 22 30 34 30 30 30 30 30 30 30 30 30 30 30  e="0400000000000
        30 31 32 22 20 73 75 62 6a 65 63 74 3d 22 4e 6f  012" subject="No
        22 20 64 61 74 65 74 69 6d 65 3d 22 32 30 31 37  " datetime="2017
        30 35 32 34 54 31 37 30 31 35 37 22 20 73 65 6e  0524T170157" sen
        64 65 72 5f 61 64 64 72 65 73 73 69 6e 67 3d 22  der_addressing="
        22 20 72 65 63 69 70 69 65 6e 74 5f 61 64 64 72  " recipient_addr
        65 73 73 69 6e 67 3d 22 35 34 33 32 31 22 20 74  essing="54321" t
        79 70 65 3d 22 53 4d 53 5f 47 53 4d 22 20 72 65  ype="SMS_GSM" re
        63 65 70 74 69 6f 6e 5f 73 74 61 74 75 73 3d 22  ception_status="
        63 6f 6d 70 6c 65 74 65 22 20 61 74 74 61 63 68  complete" attach
        6d 65 6e 74 5f 73 69 7a 65 3d 22 30 22 2f 3e 0a  ment_size="0"/>.

	... and more
2017-06-19 11:28:13 +03:00
Sathish Narasimman
a987ea04cf obexd/map: Do not send parent folder in dummy
In messages-dummy it is not necessary to add parent folder in the
response to folder-lisintg. when tested with some carkit the present
method is not working when navigating to different folders. so removing
it.
2017-06-19 11:28:13 +03:00
Luiz Augusto von Dentz
f3cc176594 obexd/pbap: Fix hanging when maxlistcount = 0
vobject_list_get_next_header shall only attempt to call
g_obex_apparam_encode otherwise it will just keep adding the same tag
in a loop.
2017-04-23 23:12:34 +03:00
Biman Paul
2322e2cc9c obexd/pbap: clear cache if name header is present
Remote device is not able to fetch call logs from different folder.
It always returns the call logs requested in first request.

Considering a situation to fetch from och and then from cch,
there are two ways to request x-bt/vcard-listing:
Case I:
1. SetPhoneBook to /telecom/och (absolute path)
2. PullvCardListing with name header '' (empty)
Remote devices using this method always calls SetPhoneBook with absolute path
to set the path and we clear the cache when new path is set.
Case II:
1. SetPhoneBook to /telecom (relative path)
2. PullvCardListing with name header 'och'
Remote devices using this method calls SetPhoneBook with '/telecom' only once
and cache is not cleared when second PullvCardListing is made with name header.
This results in cached incorrect list sent to remote device.

Clear cache if name header is present would prevent sending of
cache list as it is not present. Instead it would request to
create new cache based on new name header.
2016-09-05 12:22:46 +03:00
Fabien Proriol
8af7aac2b9 Fix obex protocol for powerpc
omtu and imtu is define as uint16_t in l2cap_get function (use with va_arg).
2016-07-29 13:58:00 +03:00
Don Zickus
03f0497691 obexd: Add a detailed failure message for exchanging business cards
When sending the ExchangeBusinessCards() command, the command returns
a failure.  It isn't clear what that failure is.  Upon looking through
the code, it is obvious the function is not implemented.

This patch just adds an extra detail message 'Not Implemented' to make
the failure a little more clear about what the problem is.
2016-07-04 14:33:53 +03:00
Marek Kasik
6c75f43e50 obexd: Return dummy_data instead of int in phonebook-dummy
There are two functions in phonebook-dummy that were returning
'int's instead of 'struct dummy_data'

phonebook_create_cache
phonebook_get_entry

As a result, when an obex-client sends the GetSize command, the obexd
on the server segfaults.

Fix this by storing the id and returning the dummy_data struct.

The GetSize test now passes correctly.
2016-07-04 14:33:16 +03:00
Marek Kasik
1610200936 obexd: Allow CreateFolder to create a directory
When the remote device sends the 'CreateFolder' command, obexd
first tries to verify the path in ftp_setpath().  Because we are
creating a new directory, the verify_path() is expected to fail (it does
not exist yet; ENOENT).

Trap that special case and cause the function to fail directly to the
create directory path.
2016-07-04 14:32:44 +03:00
Syam Sidhardhan
8175785680 obexd: client: Fix memory leaks
We have to free the allocated memory for data and its members.
2016-02-11 15:53:07 +02:00
Luiz Augusto von Dentz
c5a49786e3 obexd/session: Fix crash when disconnecting
If session owner disconnect from the bus while g_obex_connect is pending
it may lead to a crash since it is never canceled connected_cb may still
be called after callback_data is freed.
2015-11-08 20:07:51 +02:00
Marcel Holtmann
690b2a906d obexd: Use common logging function for daemon version 2015-11-08 00:44:48 +01:00
Simon Fels
d75eb5ca13 obexd: pbap: add headers correctly for size query
When client queries for the size of a phonebook we fall into a
indefinite loop as g_obex_apparam_encode always returns the same
number of items added to the buffer regardless how often it is
called. In former times where this code wasn't using GObexApparams
a array was reduced each time the headers where added and so we could
easily find out when we've added all headers. However today we need
to solve this a bit differently by also setting the firstpacket flag
when we receive the phonebook size result from the phonebook
implementation which then lets us correctly go through without
falling into a indefinite loop.
2015-10-20 14:05:02 +03:00
Luiz Augusto von Dentz
95c09761fd obexd: Fix not destroying session if owner disconnects
If the owner disconnects the session should be destroyed even if the
connection is pending:

obexd/client/session.c:owner_disconnected()
obexd/client/session.c:obc_session_shutdown() 0x822abb8
obexd/client/session.c:obc_session_ref() 0x822abb8: ref=3
obexd/client/session.c:obc_session_unref() 0x822abb8: ref=2
obexd/client/bluetooth.c:transport_connect() port 19
obexd/client/bluetooth.c:transport_callback()
obexd/client/session.c:transport_func()
obexd/client/bluetooth.c:bluetooth_getpacketopt()
obexd/client/pbap.c:pbap_probe() /org/bluez/obex/client/session1
obexd/client/session.c:obc_session_ref() 0x822abb8: ref=3
obexd/client/session.c:obc_session_register() Session(0x822abb8) registered /org/bluez/obex/client/session1
obexd/client/session.c:obc_session_unref() 0x822abb8: ref=2

To fix this the code now checks if the connect callback is pending, in
that case destroy the callback releasing the reference it carrying.
2015-09-14 10:12:30 +03:00
Luiz Augusto von Dentz
6339cced97 obexd: Fix possible crash while processing pending request
session_process_queue needs to be able to access the request .func in
case an error happen and it later calls pending_request_free so .process
shall not attempt to free the request otherwise it will cause crashes:

Invalid read of size 8
   at 0x4349D2: session_process_queue (session.c:857)
   by 0x434AC5: setpath_complete.isra.1 (session.c:1026)
   by 0x434B29: setpath_cb (session.c:1077)
   by 0x416448: handle_response (gobex.c:1128)
   by 0x41739D: incoming_data (gobex.c:1402)
   by 0x59747FA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x5974B97: ??? (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x5974EC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x40E23F: main (main.c:322)
 Address 0x66e3d30 is 32 bytes inside a block of size 56 free'd
   at 0x4C2ACE9: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x597A50E: g_free (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4345F5: pending_request_free (session.c:193)
   by 0x4348DF: session_process_setpath (session.c:1131)
   by 0x4349C9: session_process_queue (session.c:854)
   by 0x434AC5: setpath_complete.isra.1 (session.c:1026)
   by 0x434B29: setpath_cb (session.c:1077)
   by 0x416448: handle_response (gobex.c:1128)
   by 0x41739D: incoming_data (gobex.c:1402)
   by 0x59747FA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x5974B97: ??? (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x5974EC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.2)
2015-07-21 14:55:49 +03:00
Gowtham Anandha Babu
fd524d73a3 obexd/opp: Fix OPP GET request path
The default path is /etc/bluetooth/vcard.vcf which obexd
is not able to access.

obexd[11654]: obexd/src/obex.c:cmd_get() session 0x64edff0
obexd[11654]: GET(0x3), (null)(0xffffffff)
obexd[11654]: obexd/src/obex.c:parse_type() TYPE: text/x-vcard
obexd[11654]: open(/etc/bluetooth/vcard.vcf): Operation not permitted (1)
obexd[11654]: GET(0x3), NOT_FOUND(0x44)

After making this path as obex root folder,
it is able to succeed.

obexd[12246]: obexd/src/obex.c:cmd_get() session 0x64ed830
obexd[12246]: GET(0x3), (null)(0xffffffff)
obexd[12246]: obexd/src/obex.c:parse_type() TYPE: text/x-vcard
obexd[12246]: obexd/src/obex.c:driver_get_headers() name=(null) type=text/x-vcard object=0x8
obexd[12246]: GET(0x3), CONTINUE(0x10)
obexd[12246]: obexd/src/obex.c:send_data() name=(null) type=text/x-vcard file=0x8 size=3061
obexd[12246]: obexd/src/obex.c:driver_read() 73 read
obexd[12246]: obexd/src/obex.c:send_data() name=(null) type=text/x-vcard file=0x8 size=3066
obexd[12246]: obexd/src/obex.c:driver_read() 0 read
obexd[12246]: obexd/src/obex.c:transfer_complete()
2015-06-23 18:16:25 +03:00
Szymon Janc
e50c8ddde5 obexd: Remove unused parameter from manager_request_authorization
This fix compilation error with musl due to missing (now not needed)
stdint.h include.
2015-04-08 12:37:02 +02:00
Bharat Panda
982b9c322e obexd/pbap: Fix NULL check to avoid potential crash
NULL pointer check for name is done before using the same.
2015-03-20 15:37:40 +02:00
Marcel Holtmann
7a72ebec1c obexd: Fix cross includes from client and plugins 2015-03-01 01:38:12 -08:00
Marcel Holtmann
5d2afbddfd obexd: Fix includes for gobex.h header 2015-03-01 00:26:38 -08:00
Marcel Holtmann
a150d9e7c4 obexd: Fix includes for gdbus.h header 2015-03-01 00:19:28 -08:00
Marcel Holtmann
82113a16f3 obexd: Use local libbluetooth includes 2015-02-28 22:51:31 -08:00
Marcel Holtmann
d084651291 obexd: Add explicit include for lib/bluetooth.h 2015-02-18 06:24:23 +01:00
Luiz Augusto von Dentz
c16acfd544 obexd/client: Add check for invalid path
This adds a check for invalid paths in obc_session_setpath.
2015-02-13 14:27:53 +02:00
Szymon Janc
a41df6489d obexd: List all enum values in switch
As described in coding style M10.
2014-12-08 14:00:28 +01:00
Andrei Emeltchenko
4900161462 obexd: Fix comparing array to NULL
An array can never be NULL.
2014-12-04 14:26:57 +02:00
Andrei Emeltchenko
33c2e6b851 obexd: Fix memory leak not freeing desc
descs->data might be NULL while is descs not. Follow scheme in
src/profile.c (in get_profile_version() function).
2014-12-04 14:26:57 +02:00
Luiz Augusto von Dentz
5bf03cc40d obexd/client: Add supported_features support
This adds supported_features support to obc_driver so driver can
provide this information when connecting.

This is required by PBAP 1.2 (page 48):

  'Mandatory if the PSE advertises a PbapSupportedFeatures attribute in
   its SDP record, else excluded.'
2014-12-02 11:36:01 +02:00
Luiz Augusto von Dentz
2eb84f94e0 obexd/client: Add UpdateVersion to PhonebookAccess
This adds UpdateVersion method to PhonebookAccess interface.
2014-12-02 11:36:01 +02:00
Luiz Augusto von Dentz
ee0a057f44 obexd/client: Add FixedImageSize property
This adds FixedImageSize property to PhonebookAccess interface.
2014-12-02 11:36:00 +02:00
Luiz Augusto von Dentz
fb9c29020f obexd/client: Add folder counters properties
This adds PrimaryCounter and SecondaryCounter properties to
PhonebookAccess interface.
2014-12-02 11:36:00 +02:00
Luiz Augusto von Dentz
5ee26d43c6 obexd/client: Add DatabaseIdentifier property
This adds DatabaseIdentifier property to PhonebookAccess interface.
2014-12-02 11:36:00 +02:00
Luiz Augusto von Dentz
f7a8cbd2a3 obexd/client: Add Folder property
This adds Folder property to PhonebookAccess interface.
2014-12-02 11:36:00 +02:00
Luiz Augusto von Dentz
3d88b8631f obexd/client: Parse PBAP record
This add parsing to PBAP record to extract version and supported
features.
2014-12-02 11:36:00 +02:00
Luiz Augusto von Dentz
51763c0e50 obexd/client: Add support for reading version
This adds support for reading profile version via
SDP_ATTR_PFILE_DESC_LIST
2014-12-02 11:35:59 +02:00
Anurag Biradar
730c946472 pbap: Fix When MaxListCount header missing
As per spec(5.3.4.4) when MaxListCount headser is missing then
PSE should assume MaxListCount value as MAX (65535)
2014-12-01 17:12:48 +02:00
Rakesh M K
0a1d0e8968 obexd: Fix crash while session shutdown
g_str_equal has been used for the session path compare
which is not NULL-safe. Used the g_strcmp0() for the NULL-Safe
string comparision.

*#0 strcmp (p1=0x0, p2=0x7105c "/org/bluez/obex/client/session0")
*    at strcmp.c:38
*#1  0xb6e0cd0a in g_str_equal (v1=<value optimized out>,
*    v2=<value optimized out>) at ghash.c:1704
*#2  0x000264d8 in find_session (connection=<value optimized out>,
*    message=0x55b38, user_data=<value optimized out>)
*    at obexd/client/manager.c:162
*#3  remove_session (connection=<value optimized out>, message=0x55b38,
    user_data=<value optimized out>) at obexd/client/manager.c:231
2014-11-26 15:39:00 +02:00