summaryrefslogtreecommitdiff
path: root/gobex
Commit message (Collapse)AuthorAgeFilesLines
* gobex: Fix read from pointer after freeTedd Ho-Jeong An2022-02-181-0/+2
| | | | | | | | | This patch sets the pointer to null after free since the g_free(p) doesn't set the pointer to NULL. This is reported by the Coverity. Fixes: 7e7d826aa1db ("gobex: Print error if data cannot be written")
* gobex: Print error if data cannot be writtenLuiz Augusto von Dentz2022-02-141-2/+15
| | | | | This makes sure that if the data cannot be written it fails and the error is properly printed.
* build: Replace use of g_memdup with util_memdupLuiz Augusto von Dentz2022-01-062-5/+7
| | | | | | | | | | | This replaces the uses of g_memdup with util_memdup since the former has been deprecated: warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations] g_memdup2 requires bumping glib version which would likely have its own problems thus why util_memdup was introduced.
* gobex: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-2112-168/+12
| | | | | | | | | | | | | | | | | | | | | | | This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 12 License: GPL-2.0-or-later gobex/gobex-defs.h gobex/gobex-transfer.c gobex/gobex.c gobex/gobex-apparam.h gobex/gobex-header.h gobex/gobex-header.c gobex/gobex.h gobex/gobex-packet.h gobex/gobex-defs.c gobex/gobex-debug.h gobex/gobex-apparam.c gobex/gobex-packet.c
* gobex: Fix segfault caused by interrupted transferDenis Grigorev2020-07-013-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | When a obex transfer is interrupted by a peer in the middle, the response G_OBEX_RSP_FORBIDDEN comes and the transfer is freed in transfer_complete. However gobex is still ref'ed and gobex->io continues to be writable, so write_data() and then g_obex_abort() are called. When the abort response comes, struct obc_transfer is already freed, which leads to the crash. Backtrace : __GI___pthread_mutex_lock (mutex=0x65732f74) at pthread_mutex_lock.c:67 0xecc6eeda in dbus_connection_get_object_path_data () from libdbus-1.so.3 0x000457d4 in g_dbus_emit_property_changed_full () at gdbus/object.c:1794 0x00045868 in g_dbus_emit_property_changed () at gdbus/object.c:1832 0x000367f0 in transfer_set_status () at obexd/client/transfer.c:211 0x0003681e in transfer_set_status () at obexd/client/transfer.c:206 xfer_complete () at obexd/client/transfer.c:672 0x00022df6 in transfer_complete () at gobex/gobex-transfer.c:103 0x00022f44 in transfer_abort_response () at gobex/gobex-transfer.c:124 0x00020a0e in handle_response () at gobex/gobex.c:1128 0x00020dde in incoming_data () at gobex/gobex.c:1373 This commit introduces g_obex_drop_tx_queue(), which will be called if a transfer error detected. After the tx queue is dropped, obex shuts down gracefully.
* build: Move declaration of _GNU_SOURCE back into individual source filesMarcel Holtmann2018-12-061-1/+1
|
* gobex: Fix compiler warning from casting functionsMarcel Holtmann2018-05-232-2/+12
|
* gobex: Make g_obex_apparam_encode NULL safeLuiz Augusto von Dentz2017-04-231-0/+3
| | | | Make g_obex_apparam_encode ignore if the apparam pointer is NULL.
* gobex: Fix a compilation error for the compatibility with LLVMMiao-chen Chou2016-12-075-16/+16
| | | | | | | | | | The C Standard, subclause 7.16.1.4, paragraph 4 [ISO/IEC 9899:2011], states: The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter parmN is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined.
* gobex: Minor coding style (whitespace) fixJohan Hedberg2015-07-081-1/+0
|
* gobex: Fix includes for gobex.h headerMarcel Holtmann2015-03-014-8/+8
|
* gobex: List all enum values in switchSzymon Janc2014-12-081-0/+1
| | | | As described in coding style M10.
* gobex: Abort if there is no request to cancelLuiz Augusto von Dentz2014-08-291-2/+7
| | | | | If there is no request to cancel send an abort since otherwise the remote may hang waiting.
* gobex: Add g_obex_abortLuiz Augusto von Dentz2014-08-293-5/+15
|
* gobex: Fix crash when debug is enabledLuiz Augusto von Dentz2014-08-293-1/+17
| | | | | | | | | | | | | | | | GError can be NULL thus causing invalid read when trying to a message member such as bellow: Invalid read of size 8 at 0x41190F: g_obex_send_internal (gobex.c:531) by 0x4130A6: g_obex_send_req (gobex.c:756) by 0x4268A5: obc_session_unref (session.c:289) by 0x41396A: incoming_data (gobex.c:1397) 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 0x0 is not stack'd, malloc'd or (recently) free'd
* gobex: Fix warning if g_obex_resume is called when disconnectedLuiz Augusto von Dentz2014-08-291-1/+1
|
* gobex: Fix use after freeAndrei Emeltchenko2014-08-111-2/+7
| | | | Refactor function transfer_get_req_first() to avoid use after free.
* gobex: Fix use after freeAndrei Emeltchenko2014-08-111-0/+1
|
* gobex: Fix use after freeAndrei Emeltchenko2014-08-111-2/+1
| | | | It is better not to dereference freed pointer
* gobex: Fix use after freeAndrei Emeltchenko2014-08-051-0/+1
| | | | transfer_complete() frees transfer pointer.
* gobex: Fix removing invalid sourceSzymon Janc2014-04-251-5/+17
| | | | | | | | | | | | | Since GLib 2.39 calling g_source_remove on already removed source is causing critical warning. This was affecting unit/test-gobex-transfer when running with GLib 2.40. /gobex/test_packet_get_req_suspend_resume: (./unit/test-gobex-transfer:28879): GLib-CRITICAL **: Source ID 263 was not found when attempting to remove it Trace/breakpoint trap
* gobex: Fix asserting one more timeLuiz Augusto von Dentz2014-04-091-1/+1
| | | | | | | This fixes a regression caused by 35938b779dc8d2498e66e6a6483a36c1f99c2e19 where the current pending_req is set to NULL while processing the response but cause the request to timeout since it is no longer removed properly.
* gobex: Fix being able to cancel completed requestsLuiz Augusto von Dentz2014-04-081-3/+5
| | | | | This fixes bogus responses when rsp_func calls g_obex_cancel_req for responses with final bit set.
* gobex: Really fix assert this timeLuiz Augusto von Dentz2014-04-021-1/+1
|
* gobex: Fix memory leakLuiz Augusto von Dentz2014-04-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | This fixes the following leak introduced by the authentication patches: 16 bytes in 1 blocks are definitely lost in loss record 62 of 158 at 0x4C291D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E7FEC6: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x403226: prepare_auth_rsp.isra.4 (gobex.c:564) by 0x404DE4: handle_response (gobex.c:1015) by 0x405C7B: incoming_data (gobex.c:1351) by 0x4E7A2A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x4E7A627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x4E7AA39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x40DC34: test_auth (test-gobex.c:966) by 0x4E9E5E0: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x4E9E7A5: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2) by 0x4E9EB1A: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.3800.2)
* gobex: Fix asserting when resending connect requestLuiz Augusto von Dentz2014-04-021-0/+2
| | | | | | | In case connect requests needs to be resent to authenticate the timeout handle should be removed otherwise it may end up asserting: ERROR:gobex/gobex.c:251:req_timeout: assertion failed: (p != NULL)
* gobex: Respond to authentication challengeLuiz Augusto von Dentz2014-03-311-14/+113
| | | | | This implements authentication response as defined in OBEX specification since it is a mandatory feature for many Bluetooth profiles.
* gobex/header: Add g_obex_header_new_tag functionLuiz Augusto von Dentz2014-03-312-2/+8
| | | | | This function can be used to set tag using GObexApparam as argument but for arbritary headers.
* gobex: Add g_obex_disconnectLuiz Augusto von Dentz2014-03-212-0/+15
| | | | | This adds g_obex_disconnect function which can be used to send OBEX Disconnect command.
* gobex/transfer: Keep request id for GET when SRM is activeLuiz Augusto von Dentz2014-03-211-1/+6
| | | | | | In case a GET operation is in progress with SRM the same request id is valid for the whole transfer otherwise it is not possible to cancel the transfer after the first response.
* gobex: Fix not resetting SRM setupLuiz Augusto von Dentz2014-03-211-1/+2
| | | | | | | If SRM is not confirmed by both ends the setup should be disregarded and the data associated to it can be freed otherwise the next command may reuse the same setup assuming it is still valid and probably cause SRM to be enabled without remote consent.
* gobex: Handle suspending/resuming for GET when SRM is activeLuiz Augusto von Dentz2014-02-202-3/+55
| | | | | | | This adds support for suspending/resuming GET requests GET when SRM is active, in this case suspending the TX queue wont stop the remote to continue sending packets, to do that SRMP header should be set to wait so the remote should wait.
* gobex: Fix not handling SRM properlyLuiz Augusto von Dentz2014-02-201-8/+16
| | | | | SRM can be enabled but while not active with use of SRMP header so the handling of this states needs to be separated.
* gobex: Revert g_obex_pending_req_abort to static pending_req_abortLuiz Augusto von Dentz2013-09-292-4/+2
| | | | | | | This reverts the changes introduced in 9095deb82572112fc0870095bf2222964610eafe that made pending_req_abort public which is not necessary considering g_obex_cancel_req can do the same and is safe to call even if the request is not pending.
* gobex: Fix crash on g_obex_pending_req_abortLuiz Augusto von Dentz2013-09-291-1/+4
| | | | | | | | | | | | | | | | | | | It is not safe to call g_obex_pending_req_abort directly as pending_req can be NULL: Invalid read of size 4 at 0x41231E: g_obex_pending_req_abort (gobex.c:693) by 0x416A8A: g_obex_cancel_transfer (gobex-transfer.c:647) by 0x42DEF2: obc_transfer_cancel (transfer.c:180) by 0x43D833: 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 0x43A5B7: 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) by 0x3B03C48157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3) by 0x3B03C48559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3) by 0x40D53C: main (main.c:319) Address 0x30 is not stack'd, malloc'd or (recently) free'd
* codingstyle: Change __FUNCTION__ to __func__Andrei Emeltchenko2013-09-111-1/+1
| | | | | | | | | | The __func__ macro is part of the C99 standard whereas __FUNCTION__ is a legacy gcc specific alias for it: http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html Additionally, checkpatch.pl that's commonly used to verify coding style also recommends to use __func__ instead of __FUNCTION__.
* gobex: Add proper message to transfer errorsLuiz Augusto von Dentz2013-08-121-2/+2
| | | | | This improve the error message when a transfer fails by using g_obex_strerror to decode the response code to a human readable string.
* gobex: Get rid of gcharLucas De Marchi2013-05-021-8/+8
| | | | Use plain char instead of gchar.
* gobex: Get rid of gintLucas De Marchi2013-05-012-8/+8
| | | | | Use plain int instead of gint. In glib gint is always a typedef to int, so it's safe to use it even for callbacks with glib.
* gobex: Use gcc builtin instead of g_atomicLucas De Marchi2013-04-091-6/+8
| | | | | | | | | | | | | g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to -Wunused-local-typedefs. /usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs] #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] Most of the uses of atomic operations were wrong. They were fixed as well. If we are using atomic operations, reading the variable again later for logging is not an option, we should use the return of the atomic function used to fetch the variable.
* gobex: Fix GPL version referenceJohan Hedberg2013-02-1512-24/+36
| | | | | These files (like everything else in the tree) should be GPL 2 or later instead of GPL 2 only.
* Revert "Ensure config.h is included by using CPPFLAGS"Johan Hedberg2012-12-076-0/+24
| | | | | | | | | | | | | | This reverts commit 8a03376544b046a84301847d1594f6c3674983ff. 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
* Ensure config.h is included by using CPPFLAGSLucas De Marchi2012-12-056-24/+0
| | | | | | | | | | 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.
* gobex: Fix build on 32 bits systemsLuiz Augusto von Dentz2012-12-041-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GUINT_TO_POINTER does not cast properly in older version of GLib (< 2.31) causing the following errors: cc1: warnings being treated as errors gobex/gobex-apparam.c: In function ‘g_obex_apparam_set_bytes’: gobex/gobex-apparam.c:176:38: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_uint8’: gobex/gobex-apparam.c:243:43: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_uint16’: gobex/gobex-apparam.c:261:43: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_uint32’: gobex/gobex-apparam.c:282:43: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_uint64’: gobex/gobex-apparam.c:303:43: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_string’: gobex/gobex-apparam.c:324:43: error: cast to pointer from integer of different size gobex/gobex-apparam.c: In function ‘g_obex_apparam_get_bytes’: gobex/gobex-apparam.c:342:43: error: cast to pointer from integer of different size make[1]: *** [gobex/gobex-apparam.o] Error 1 make: *** [all] Error 2
* gobex: Add debug option to apparamLuiz Augusto von Dentz2012-12-043-9/+52
| | | | This adds "apparam" to the debug options of GOBEX_DEBUG
* gobex: Integrate GObexApparam with GObexHeaderLuiz Augusto von Dentz2012-12-042-0/+28
| | | | | | This introduce 2 new convenient functions: g_obex_header_get_apparam which parses and decode an header into GObexApparam and gobex_header_new_apparam that encode GObexApparam into GObexHeader.
* gobex: Introduce GObexApparam APILuiz Augusto von Dentz2012-12-042-0/+373
| | | | | | | GObexApparam abstract the handling of application parameter tags, it can be used to read/parse application parameter header data using g_obex_apparam_get_* functions or to generate the data using g_obex_apparam_set_*.
* gobex: Fix not printing debug messages when GOBEX_DEBUG is setLuiz Augusto von Dentz2012-12-042-4/+6
| | | | | g_debug doesn't print anything if domain is not present in G_MESSAGES_DEBUG.
* gobex: Change UTF name to standardNeal Peacock2012-12-041-1/+1
|
* gobex: Fix dead assignments in gobex-header.cSzymon Janc2012-12-041-5/+5
| | | | Values stored are never read.