Commit Graph

1411 Commits

Author SHA1 Message Date
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
Bharat Panda
11703a49f4 obexd/ftp: Handle transfer reset for FTP
Changes made to emit transfer completed to .Transfer1 interface on
ftp reset.
2014-11-04 11:11:18 +02:00
Bharat Panda
1e5a31d5c2 obexd/ftp: Add support for tracking transfers
This enables transfer management for FTP connections.
2014-10-31 16:52:02 +02:00
Bharat Panda
53d39af1e7 obexd/mas: Handle register notification open
Changes made to handle method open for mime_notification_registration
2014-10-29 16:42:37 +02:00
Bharat Panda
60071dd2a1 obexd/mas: Add Support for MSETime filter
Changes made to add support for MSE local time and timezone offset
parameter along with GetMessageListing response.
2014-10-22 16:49:37 +03:00
Gowtham Anandha Babu
1c5f3cf0cf obexd/map: Add support for MAP feature bits
Handles MAP supported feature bits as per the
MAP 1.2 specs section 7.1.1.
2014-10-22 11:57:19 +03:00
Gowtham Anandha Babu
aa649eeb5e obexd: Fix coding style and improves readability 2014-10-16 10:13:01 +02:00
Gowtham Anandha Babu
faba6c6e41 obexd/client/pbap: Add missing filter entries
Adds the following filter entries:
1) Speed-dial
2) Uniform Caller Identifier
3) Unique Identifier
2014-10-16 09:43:04 +02:00
Gowtham Anandha Babu
d0f7fd035f obexd/client/pbap: Add support for spd,fav
Add support for the speed-dial and favorite folders.
2014-10-16 09:43:04 +02:00
Szymon Janc
29ec84e8d2 obexd: Fix compilation error with musl
CC       obexd/plugins/obexd-filesystem.o
In file included from obexd/plugins/filesystem.c:40:0:
/usr/include/wait.h:1:2: error: #warning redirecting incorrect
    #include <wait.h> to <sys/wait.h> [-Werror=cpp]
 #warning redirecting incorrect #include <wait.h> to <sys/wait.h>
  ^
cc1: all warnings being treated as errors
Makefile:6447: recipe for target 'obexd/plugins/obexd-filesystem.o' failed
make[1]: *** [obexd/plugins/obexd-filesystem.o] Error 1
2014-09-24 21:31:13 +03:00
Gowtham Anandha Babu
cf5361615e obexd: Fix the double check for agent
Removes the check for NULL agent.
2014-09-22 19:06:48 +03:00
Gowtham Anandha Babu
7e03d3d92f obexd/client: Add support for MAP Event Report 1.1
This adds support for Event Report 1.1 of MAP 1.2 which includes the
following atributes: Subject, datetime, sender_name, priority.
2014-09-17 11:16:37 +03:00
Gowtham Anandha Babu
621861cd84 obexd/client/map: Check msg value is valid
Checks for NULL value before passing to the callback.
2014-09-16 10:19:03 +03:00
Luiz Augusto von Dentz
60ebd27931 obexd/mns: Check event value is valid
This adds a common check before passing the event value to the callback.
2014-09-15 14:50:39 +03:00
Luiz Augusto von Dentz
bb57098100 obexd/client: Fix leaking memory on MNS
In case an event is received twice, due to remote side misbehaving or
not, it would leak the previous data.
2014-09-15 14:50:39 +03:00
Luiz Augusto von Dentz
498e067aba obexd/mas: Fix crash when outparams is NULL
outparams can be NULL meaning no application parameters should be added
to the response.
2014-09-03 16:28:01 +03:00
Luiz Augusto von Dentz
55eebc598b obexd/mas: Fix parsing of application parameters
Some commands don't have any mandatory application parameter which means
inparams can be NULL which should not be treated as a bad request.
2014-09-03 14:36:31 +03:00
Luiz Augusto von Dentz
765fc36308 obexd/client: Fix crash while disconnecting
In case the transport is disconnected while disconnect command is pending
the session is freed on disconnect_complete but disconnect callback is
still valid causing the following crash:

Invalid read of size 4
   at 0x42682A: obc_session_ref (session.c:132)
   by 0x42797B: obc_session_shutdown (session.c:580)
   by 0x4139DA: incoming_data (gobex.c:1406)
   by 0x59712A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x5971627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x5971A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x40D78C: main (main.c:320)
 Address 0x728d814 is 4 bytes inside a block of size 120 free'd
   at 0x4C28577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5976F7E: g_free (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x4134B9: handle_response (gobex.c:1129)
   by 0x4139BD: incoming_data (gobex.c:1403)
   by 0x59712A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x5971627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x5971A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x40D78C: main (main.c:320)
2014-08-29 10:32:26 +03:00
Luiz Augusto von Dentz
a3fd6fe629 obexd/client: Fix not being able to cancel a suspended transfer
If a transfer is suspended it should be resumed before cancelling
otherwise it will timeout.
2014-08-29 10:32:26 +03:00
Luiz Augusto von Dentz
ea2636c565 obexd/client: Allow suspending transfer while they are queued
Transfer may be created by different processes so it make sense to allow
them to be suspended even if they are not active.
2014-08-29 10:32:26 +03:00
Andrei Emeltchenko
be5df37961 obexd: Fix possible NULL dereference
Remove snprintf error check. Fixes clang warnings below:
...
obexd/client/map.c:471:9: warning: Access to field 'message' results in
a dereference of a null pointer (loaded from variable 'err')
                                                           err->message);
                                                           ^~~~~~~~~~~~
obexd/client/map.c:772:9: warning: Access to field 'message' results in
a dereference of a null pointer (loaded from variable 'err')
                                                           err->message);
                                                           ^~~~~~~~~~~~
...
2014-08-13 12:17:24 +03:00
Andrei Emeltchenko
f937ca0167 obexd: Fix memory leak
Fixes memory leak for message_listing_cb()
2014-08-04 09:10:57 +03:00
Andrei Emeltchenko
68fc5cb2bd obexd: Fix memory leak
Fixes memory leak for folder_listing_cb().
2014-08-04 09:10:55 +03:00
Luiz Augusto von Dentz
b458fd41c2 obexd: Fix treating PUT with Body header as delete
Requests have the size set to OBJECT_SIZE_DELETE but if the request has
a body header the size should be set to OBJECT_SIZE_UNKNOWN as it no
longer can be considered a delete request:

  "3.4.3.6 Put-Delete and Create-Empty Methods

   A PUT operation with NO Body or End-of-Body headers whatsoever should
   be treated as a delete request."
2014-04-23 17:55:15 +03:00
Luiz Augusto von Dentz
1d23383bfe obexd/client: Fix calling g_obex_cancel_req for completed requests
This leads to incorrect responses such as the following:

> ACL data: handle 12 flags 0x02 dlen 26
    L2CAP(d): cid 0x0041 len 22 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 38 pf 0 ilen 18 fcs 0xfd
        OBEX: Get rsp(f): status 200 len 18
        Status 200 = Success
        Connection ID (0xcb) = 1
        App. Parameters (0x4c) = Sequence length 4
        End of Body (0x49) = Sequence length 0
< ACL data: handle 12 flags 0x00 dlen 11
    L2CAP(d): cid 0x0040 len 7 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 38 pf 0 ilen 3 fcs 0x27
        OBEX: Get rsp(f): status 715 len 3
2014-04-08 16:27:49 +03:00
Luiz Augusto von Dentz
00d4081aa9 obexd: Remove code related to OBEX authentication
gobex can now generate responses authentication challenge so this code
is no longer needed.
2014-03-31 17:30:59 +03:00
Luiz Augusto von Dentz
b35cdac7b1 obexd/client: Fix not sending OBEX Disconnect when disconnecting
Sending OBEX Disconnect command before disconnecting the transport is
mandatory.
2014-03-21 16:13:45 +02:00
Luiz Augusto von Dentz
3bf9192cf2 obexd/client: Fix not being able cancel GET requests
In case of GET operation the code does not use g_obex_get_req_pkt since
the beggining to be able to read the header from the first response, this
means that the request should be cancel with g_obex_cancel_req not with
g_obex_cancel_transfer.
2014-03-20 16:23:55 +02:00
Luiz Augusto von Dentz
d4390c088c obexd/transfer: Add Transfer.Resume method
This method can be used to resume ongoing transfers.
2014-02-20 12:45:59 +02:00
Luiz Augusto von Dentz
ff10649bd2 obexd/transfer: Add Transfer.Suspend method
This method can be used to suspend ongoing transfers.
2014-02-20 12:45:59 +02:00
Hannu Mallat
286216b9a8 pbap: Fix PhonebookSize endianness
As g_obex_apparam_set_uint16() converts data to big-endian format
internally, do not call htons() prior to it.
2014-02-05 13:19:06 +02:00
Marcel Holtmann
8ed6c3815c obexd: Make btio/btio.h include local 2014-01-25 20:33:04 -08:00
Harald Schmitt
9cf18f0b4c obexd/irmc: Fix folder for LUID requests
The old macro PB_LUID_FOLDER had the folder luid on the second level:
/telecom/luid. But the luid folder occurs per IrMC spec on level three
e.g. /telecom/pb/luid.
2014-01-20 21:25:47 +02:00
Bastien Nocera
841896ae17 obex: Use user's cache dir as a default root
It's per-user, so we won't try to overwrite somebody else's
files in /tmp when that happens. It's also (unless we have a
particularly bizarre setup) on the same partition as the destination
folder which means we can atomically move the file to the destination
with a unique filename.
2013-11-12 10:55:28 +02:00
Luiz Augusto von Dentz
b3b5fc6229 obexd/session: Fix crash when transport is disconnected
When transport is disconnected unexpectedly it can cause the following
crash:
gobex-DEBUG: gobex/gobex.c:g_obex_send_internal() The transport is not connected
Invalid read of size 8
   at 0x42662E: session_process_queue (session.c:789)
   by 0x42668F: session_process (session.c:719)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40D5FC: main (main.c:319)
 Address 0x5086760 is 32 bytes inside a block of size 56 free'd
   at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3D4604D9AE: g_free (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x426146: session_process_setpath (session.c:1063)
   by 0x426629: session_process_queue (session.c:786)
   by 0x42668F: session_process (session.c:719)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40D5FC: main (main.c:319)
2013-10-15 09:56:45 +03:00
Luiz Augusto von Dentz
a01efa88a7 obexd/MAP: Fix parsing message handles as decimal numbers
The spec clearly states the handles are hexadecimal:

MAP 1.2 - Page 29

  ""handle" is the message handle in hexadecimal representation with up
  to 16 digits; leading zero digits may be used so the MCE shall accept
  both handles with and without leading zeros (e.g.,"00000012345678AB"
  or "12345678AB")."
2013-10-09 17:37:44 +02:00
Luiz Augusto von Dentz
fd02ee7b32 obexd/MAP: Fix sending \0 after filler byte
It is not necessary to append \0 after the filler byte (0x30), the spec
just talk about the a byte not bytes.
2013-10-09 17:37:41 +02:00
Luiz Augusto von Dentz
ce3b7eab71 obexd/session: Fix crash while disconnecting
Requests need to be cancelled when obc_session_shutdown is called
otherwise they can trigger the callback with invalid/freed data as in
the following backtrace:
Invalid read of size 8
   at 0x426684: setpath_cb (session.c:998)
   by 0x412AEB: handle_response (gobex.c:949)
   by 0x413010: incoming_data (gobex.c:1192)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40D59C: main (main.c:319)
 Address 0x571f598 is 40 bytes inside a block of size 56 free'd
   at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3D4604D9AE: g_free (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x426EA9: obc_session_shutdown (session.c:555)
   by 0x4254B4: remove_session (manager.c:62)
   by 0x43DC53: process_message.isra.5 (object.c:259)
   by 0x3D4981CE85: ??? (in /usr/lib64/libdbus-1.so.3.7.4)
   by 0x3D4980FA30: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.4)
   by 0x43A9D7: message_dispatch (mainloop.c:76)
   by 0x3D46048962: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
2013-10-07 19:02:43 +03:00
Szymon Janc
15777b97b4 obexd/MAP: Fix protected property value
"Sent" flag value was returned instead of "Protected" one.
This also fix following build error:

  CC     obexd/client/obexd-map.o
obexd/client/map.c:711:17: error: ‘get_protected’ defined but not
    used [-Werror=unused-function]
cc1: all warnings being treated as errors
2013-10-04 14:10:33 +03:00
Szymon Janc
2acbd111a9 obexd/client: Remove unused static functions
This fix following build error:

  CC     obexd/client/obexd-dbus.o
obexd/client/dbus.c:70:13: error: ‘append_array_variant’ defined but
    not used [-Werror=unused-function]
obexd/client/dbus.c:97:13: error: ‘append_dict_variant’ defined but
    not used [-Werror=unused-function]
2013-10-04 14:10:33 +03:00
Szymon Janc
9cd1d095e2 client/transfer: Return "error" for unknown status in status2str
This can happen only if there is a bug in obexd code.
This fix following build error:

  CC     obexd/client/obexd-transfer.o
obexd/client/transfer.c: In function ‘status2str’:
obexd/client/transfer.c:277:1: error: control reaches end of non-void
    function [-Werror=return-type]
2013-10-04 14:10:33 +03:00
Szymon Janc
757e10de01 obexd/MAP: Fix missing include
This fix following build error:

  CC     obexd/client/obexd-map.o
obexd/client/map.c: In function ‘msg_element’:
obexd/client/map.c:1113:2: error: implicit declaration of function ‘strtoull’ [-Werror=implicit-function-declaration]
2013-10-04 14:10:33 +03:00
Szymon Janc
5cbc2e68ff obexd/service: Remove unused local variable
This fix following build error:

  CC     obexd/src/obexd-service.o
obexd/src/service.c: In function ‘obex_service_driver_register’:
obexd/src/service.c💯10: error: unused variable ‘l’ [-Werror=unused-variable]
2013-10-04 14:10:33 +03:00
Szymon Janc
bce50703cd obexd: Return "error" for unknown status in status2str
This can happend only if there is a bug in obexd code.
This fix following buld error:

  CC     obexd/src/obexd-manager.o
obexd/src/manager.c: In function ‘status2str’:
obexd/src/manager.c:292:1: error: control reaches end of non-void
    function [-Werror=return-type]
2013-10-04 14:10:33 +03:00
Szymon Janc
c8f07de497 obexd: Remove unused local variables
This fix following build errors:

obexd/src/manager.c: In function ‘get_root’:
obexd/src/manager.c:253:23: error: unused variable ‘os’
    [-Werror=unused-variable]

obexd/src/manager.c: In function ‘manager_emit_transfer_started’:
obexd/src/manager.c:534:22: error: unused variable ‘id’
    [-Werror=unused-variable]

obexd/src/manager.c: In function ‘manager_request_authorization’:
obexd/src/manager.c:684:14: error: unused variable ‘type’
    [-Werror=unused-variable]
obexd/src/manager.c:683:14: error: unused variable ‘filename’
    [-Werror=unused-variable]
2013-10-04 14:10:33 +03:00
Szymon Janc
f3a0cd30b7 obexd: Remove unused static functions
This fix following build error:

obexd/src/manager.c: At top level:
obexd/src/manager.c:190:13: error:
     ‘dbus_message_iter_append_dict_entry’ defined but not used
     [-Werror=unused-function]
2013-10-04 14:10:33 +03:00
Szymon Janc
d606c25221 obexd/MAP: Remove unused mas_drivers variable
This fix following build error:

  CC     obexd/client/obexd-mns.o
obexd/client/mns.c:344:38: error: ‘mas_drivers’ defined but not used
    [-Werror=unused-variable]
cc1: all warnings being treated as errors
2013-10-04 14:10:33 +03:00
Szymon Janc
21d3b9c3b2 obexd/MAP: Fix missing include
This fix following build error:

  CC     obexd/client/obexd-mns.o
obexd/client/mns.c: In function ‘parse_event_report_handle’:
obexd/client/mns.c:187:2: error: implicit declaration of function
    ‘strtoull’ [-Werror=implicit-function-declaration]
2013-10-04 14:10:33 +03:00
Szymon Janc
fcc8b020d8 obexd/MAP: Fix missing include
This fix following build error:

  CC     obexd/client/obexd-mns.o
obexd/client/mns.c: In function ‘mns_connect’:
obexd/client/mns.c:105:2: error: implicit declaration of function
    ‘manager_register_session’ [-Werror=implicit-function-declaration]
obexd/client/mns.c: In function ‘mns_disconnect’:
obexd/client/mns.c:128:2: error: implicit declaration of function
    ‘manager_unregister_session’ [-Werror=implicit-function-declaration]
2013-10-04 14:10:16 +03:00
Szymon Janc
a78dae8289 obexd/bluetooth: Make dict_append_entry function static
This fix following build error:

  CC     obexd/plugins/obexd-bluetooth.o
obexd/plugins/bluetooth.c:242:6: error: no previous declaration for
     ‘dict_append_entry’ [-Werror=missing-declarations]
2013-10-04 12:21:52 +03:00
Szymon Janc
d0b3d72fea obexd/bluetooth: Remove unused local variables
This ix following build errors:

  CC     obexd/plugins/obexd-bluetooth.o
obexd/plugins/bluetooth.c: In function ‘register_profile_reply’:
obexd/plugins/bluetooth.c:202:10: error: unused variable ‘err’
    [-Werror=unused-variable]

obexd/plugins/bluetooth.c: In function ‘name_acquired’:
obexd/plugins/bluetooth.c:367:15: error: unused variable ‘uuid’
    [-Werror=unused-variable]

obexd/plugins/bluetooth.c: In function ‘name_released’:
obexd/plugins/bluetooth.c:389:15: error: unused variable ‘uuid’
    [-Werror=unused-variable]

obexd/plugins/bluetooth.c: In function ‘bluetooth_start’:
obexd/plugins/bluetooth.c:400:10: error: unused variable ‘ios’
    [-Werror=unused-variable]
2013-10-04 12:21:52 +03:00
Szymon Janc
c1ab916342 obexd/MAP: Fix invalid snprintf format string in map_msg_get()
obexd/client/map.c: In function ‘map_msg_get’:
obexd/client/map.c:446:2: warning: format ‘%u’ expects argument of type
     ‘unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat]
obexd/client/map.c:446:2: warning: format ‘%u’ expects argument of type
     ‘unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat]
2013-10-04 10:33:13 +03:00
Luiz Augusto von Dentz
de40e1d3b2 obexd/MAP: Store message handle in binary format
This is more efficient in terms of memory and hash lookups, it is also
not prone to string format bugs in remote stacks such as leading zeros
being treated as a different handle as can be experience with
Nokia N950 which sends events using a handle with leading zeros but
message listing don't have them.
2013-10-03 16:46:41 +03:00
Luiz Augusto von Dentz
27bb25c130 obexd/session: Fix crash while processing command queue
session_process_queue can call a callback which can cause the session to
be freed:
Invalid write of size 4
   at 0x4265C9: session_process (session.c:716)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40D55C: main (main.c:319)
 Address 0x4d658a8 is 104 bytes inside a block of size 120 free'd
   at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3D4604D9AE: g_free (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x4265B1: session_process_queue (session.c:794)
   by 0x4265C8: session_process (session.c:714)
   by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40D55C: main (main.c:319)
2013-10-03 16:46:41 +03:00
Christian Fetzer
8b6966a72f obexd: Prefix folders in event reports with leading slash
The internal representation of folder paths starts with a leading slash.
Therefore we have to prepend it to the folders received in event reports.
2013-10-03 16:46:41 +03:00
Christian Fetzer
c55ebae431 obexd: Handle message shift and message deleted events
Update Folder propery if the message has been shifted or deleted.
2013-10-03 16:46:41 +03:00
Christian Fetzer
0e346308d8 obexd: Handle message status events
For outgoing messages, the message status is changed when an event
indicates that the sending/delivery has failed or succeeded.
2013-10-03 16:46:41 +03:00
Christian Fetzer
d4d2b1a1dd obexd: Handle new message event
Register new org.bluez.obex.Message1 D-Bus object when a NewMessage
event report has arrived.
2013-10-03 16:46:40 +03:00
Christian Fetzer
4d96b9beed obexd: Fix emitting Type property changed signals for messages
In order to determine if the message Type property has changed,
the stored type needs to be compared with the parsed type and not with
the raw value received from the MSE.

This fixes the issue that the property changed signal for the Type
property is emitted for every message on every ListMessage call.
2013-10-02 15:27:22 +03:00
Luiz Augusto von Dentz
ed6baf1417 obexd/client: Fix not setting Transfer.Size for GET operations
GET operations may return the length header in the first response which
should be set as transfer Size property.
2013-09-29 17:01:07 +03:00
Luiz Augusto von Dentz
4b354f1c3d obexd/bluetooth: Fix memory leak when adapter is off
sdp_connect fails when Bluetooth adapter is off which leads to the
following leak:
37 bytes in 1 blocks are definitely lost in loss record 68 of 165
   at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3B03C4D89E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3B03C64BAE: g_strdup (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x427D5D: bluetooth_connect (bluetooth.c:410)
   by 0x426CC9: obc_session_create (session.c:454)
   by 0x425693: create_session (manager.c:203)
   by 0x43D8A3: process_message.isra.5 (object.c:259)
   by 0x3B0701CE85: ??? (in /usr/lib64/libdbus-1.so.3.7.4)
   by 0x3B0700FA30: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.4)
   by 0x43A627: message_dispatch (mainloop.c:76)
   by 0x3B03C48962: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3B03C47E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
2013-09-26 15:53:37 +03:00
Christian Fetzer
f6e2691c08 obexd: Fix setting message folder for relative folder in ListMessages
The method ListMessages allows to specify a relative subfolder.
This subfolder needs to be added to the current path when registering
a new message interface.
2013-09-26 15:47:30 +03:00
Christian Fetzer
0c254a0415 obexd: Add folder property to map_msg_create
Message interfaces are not necessarily created for the current folder,
therefore the folder needs to be specified in a parameter.

For example, messages can be created for sub folders when using the folder
parameter in ListMessages.
2013-09-26 15:34:06 +03:00
Luiz Augusto von Dentz
f4374b0790 obexd/service: Fix possible leaking drivers list
When registering a new driver with obex_service_driver_register there
could exist another driver for the service which will cause the drivers
list to leak.
2013-09-25 11:40:12 +03:00
Luiz Augusto von Dentz
d6b20f4df6 obexd/server: Fix leaking drivers list
The leak can be detected by using G_SLICE=always-malloc which will
produce the following trace using valgrind:
112 bytes in 7 blocks are definitely lost in loss record 123 of 167
   at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3B03C4D89E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3B03C6344D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x3B03C647A5: g_slist_append (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x424DD3: obex_service_driver_list (service.c:76)
   by 0x42517F: obex_server_init (server.c:64)
   by 0x40D439: main (main.c:304)
2013-09-25 11:40:12 +03:00
Luiz Augusto von Dentz
6ae5bc7846 obexd/bluetooth: Fix memory leak
g_io_channel_unix_new creates a reference which is then passed to
obex_session_start which creates its on reference via g_io_channel_ref
leading to the following leak:

at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x3B03C4D89E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3B03C88224: g_io_channel_unix_new (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x418967: profile_new_connection (bluetooth.c:148)
by 0x43D763: process_message.isra.5 (object.c:259)
2013-09-16 13:35:10 +03:00
Christian Fetzer
829f5dc298 obexd: Remove msg from MAP session structure
The D-Bus message for a pending method call is now stored in the
pending_request struct.
2013-09-16 12:59:55 +03:00
Christian Fetzer
0416930e7e obexd: Use pending request in UpdateInbox 2013-09-16 12:59:54 +03:00
Christian Fetzer
1852ab4e7b obexd: Use pending request in ListMessages 2013-09-16 12:59:54 +03:00
Christian Fetzer
0b74a2e096 obexd: Use pending request in ListFolders 2013-09-16 12:59:54 +03:00
Christian Fetzer
0c182183c9 obexd: Use pending request in SetFolder 2013-09-16 12:59:54 +03:00
Christian Fetzer
762d523986 obexd: Add request struct to MAP
This adds a pending_request struct in order to store the D-Bus request
data.

The current version stores the received D-Bus message in the MAP session
struct. The stored message is overridden by intermediate D-Bus method
calls which can lead into a crash.

Trace:
  arguments to dbus_message_unref() were incorrect,
  assertion "!message->in_cache" failed in file dbus-message.c line 1618.

 0  0x00007ffff6a6a1c9 in raise () from /usr/lib/libc.so.6
 1  0x00007ffff6a6b5c8 in abort () from /usr/lib/libc.so.6
 2  0x00007ffff7313de5 in ?? () from /usr/lib/libdbus-1.so.3
 3  0x00007ffff730ab91 in ?? () from /usr/lib/libdbus-1.so.3
 4  0x000000000043721c in message_listing_cb (session=0x6a7d30,
    transfer=0x6a9450, err=0x0, user_data=0x6a9950) at obexd/client/map.c:1166
 5  0x000000000042f7af in session_terminate_transfer (session=0x6a7d30,
    transfer=0x6a9450, gerr=0x0) at obexd/client/session.c:830
 6  0x000000000042f83d in session_notify_complete (session=0x6a7d30,
    transfer=0x6a9450) at obexd/client/session.c:845
 7  0x000000000042f8dc in transfer_complete (transfer=0x6a9450, err=0x0,
    user_data=0x6a7d30) at obexd/client/session.c:865
 8  0x0000000000439ee7 in xfer_complete (obex=0x677250, err=0x0,
    user_data=0x6a9450) at obexd/client/transfer.c:577
 9  0x000000000043a05f in get_xfer_progress_first (obex=0x677250, err=0x0,
    rsp=0x678730, user_data=0x6a9450) at obexd/client/transfer.c:621
 10 0x0000000000413f08 in handle_response (obex=0x677250, err=0x0,
    rsp=0x678730) at gobex/gobex.c:949
 11 0x00000000004147db in incoming_data (io=0x6a8a00, cond=G_IO_IN,
    user_data=0x677250) at gobex/gobex.c:1192
 12 0x00007ffff702dda6 in g_main_context_dispatch ()
   from /usr/lib/libglib-2.0.so.0
 13 0x00007ffff702e0f8 in ?? () from /usr/lib/libglib-2.0.so.0
 14 0x00007ffff702e4fa in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
 15 0x0000000000427ce8 in main (argc=1, argv=0x7fffffffdd48)
    at obexd/src/main.c:319
2013-09-16 12:59:54 +03:00