From: Claudio Takahasi <cktakahasi@gmail.com>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] HCID D-Bus (Seg Fault)
Date: Wed, 14 Sep 2005 09:00:32 -0300 [thread overview]
Message-ID: <e1effdeb0509140500650ec0c0@mail.gmail.com> (raw)
In-Reply-To: <1126637659.9456.0.camel@localhost.localdomain>
[-- Attachment #1.1: Type: text/plain, Size: 877 bytes --]
Hi Marcel,
It's done! The changes was based on the dbus.c revision 1.15.
Regards,
Claudio.
On 9/13/05, Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Claudio,
>
> > The patch for reply_handler_function is attached.
>
> please redo it against the latest CVS, because I already dropped the
> D-Bus 0.23 support.
>
> Regards
>
> Marcel
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download it for free - -and be entered to win a 42" plasma tv or your very
> own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
[-- Attachment #1.2: Type: text/html, Size: 1366 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hcid_dbus_0004.patch --]
[-- Type: text/x-patch; name="hcid_dbus_0004.patch", Size: 3290 bytes --]
--- bluez-utils-cvs.orig/hcid/dbus.c 2005-09-14 08:51:58.470937024 -0300
+++ bluez-utils-cvs/hcid/dbus.c 2005-09-14 08:46:09.853934864 -0300
@@ -64,43 +64,54 @@
static void reply_handler_function(DBusPendingCall *call, void *user_data)
{
- struct pin_request *req = (struct pin_request *) user_data;
- pin_code_reply_cp pr;
- DBusMessage *message;
- DBusMessageIter iter;
- int type;
- size_t len;
- char *pin;
-
- message = dbus_pending_call_steal_reply(call);
-
- if (dbus_message_is_error(message, WRONG_ARGS_ERROR))
- goto error;
-
- dbus_message_iter_init(message, &iter);
-
- type = dbus_message_iter_get_arg_type(&iter);
- if (type != DBUS_TYPE_STRING)
- goto error;
-
- dbus_message_iter_get_basic(&iter, &pin);
- len = strlen(pin);
-
- memset(&pr, 0, sizeof(pr));
- bacpy(&pr.bdaddr, &req->bda);
- memcpy(pr.pin_code, pin, len);
- pr.pin_len = len;
- hci_send_cmd(req->dev, OGF_LINK_CTL, OCF_PIN_CODE_REPLY,
- PIN_CODE_REPLY_CP_SIZE, &pr);
-
- dbus_message_unref(message);
- dbus_pending_call_unref(call);
-
- return;
-
-error:
- hci_send_cmd(req->dev, OGF_LINK_CTL,
- OCF_PIN_CODE_NEG_REPLY, 6, &req->bda);
+ struct pin_request *req = (struct pin_request *) user_data;
+ pin_code_reply_cp pr;
+ DBusMessage *message;
+ DBusMessageIter iter;
+ int arg_type;
+ int msg_type;
+ size_t len;
+ char *pin;
+ const char *error_msg;
+
+ message = dbus_pending_call_steal_reply(call);
+
+ if (message) {
+ msg_type = dbus_message_get_type(message);
+ dbus_message_iter_init(message, &iter);
+
+ if (msg_type == DBUS_MESSAGE_TYPE_ERROR) {
+ dbus_message_iter_get_basic(&iter, &error_msg);
+ /* handling WRONG_ARGS_ERROR, DBUS_ERROR_NO_REPLY, DBUS_ERROR_SERVICE_UNKNOWN */
+ syslog(LOG_ERR, "%s: %s", dbus_message_get_error_name(message), error_msg);
+
+ hci_send_cmd(req->dev, OGF_LINK_CTL,
+ OCF_PIN_CODE_NEG_REPLY, 6, &req->bda);
+ } else {
+ /* check signature */
+ arg_type = dbus_message_iter_get_arg_type(&iter);
+ if (arg_type != DBUS_TYPE_STRING) {
+ syslog(LOG_ERR, "Wrong reply signature: expected PIN");
+
+ hci_send_cmd(req->dev, OGF_LINK_CTL,
+ OCF_PIN_CODE_NEG_REPLY, 6, &req->bda);
+ } else {
+ dbus_message_iter_get_basic(&iter, &pin);
+
+ len = strlen(pin);
+
+ memset(&pr, 0, sizeof(pr));
+ bacpy(&pr.bdaddr, &req->bda);
+ memcpy(pr.pin_code, pin, len);
+ pr.pin_len = len;
+ hci_send_cmd(req->dev, OGF_LINK_CTL, OCF_PIN_CODE_REPLY,
+ PIN_CODE_REPLY_CP_SIZE, &pr);
+ }
+
+ }
+ dbus_message_unref(message);
+ }
+ dbus_pending_call_unref(call);
}
static void free_pin_req(void *req)
next prev parent reply other threads:[~2005-09-14 12:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-08 19:50 [Bluez-devel] HCID D-Bus Claudio Takahasi
2005-09-08 23:07 ` Marcel Holtmann
2005-09-09 8:25 ` Peter Robinson
2005-09-09 9:37 ` Marcel Holtmann
2005-09-09 13:29 ` Sjoerd Simons
2005-09-09 13:40 ` Marcel Holtmann
2005-09-12 21:07 ` [Bluez-devel] HCID D-Bus (Sig Fault) Claudio Takahasi
2005-09-12 21:14 ` [Bluez-devel] HCID D-Bus (Seg Fault) Claudio Takahasi
2005-09-12 21:40 ` [Bluez-devel] HCID D-Bus (Sig Fault) Marcel Holtmann
2005-09-12 23:09 ` Claudio Takahasi
2005-09-12 23:21 ` Marcel Holtmann
2005-09-13 13:03 ` [Bluez-devel] HCID D-Bus (Seg Fault) Claudio Takahasi
2005-09-13 18:54 ` Marcel Holtmann
2005-09-14 12:00 ` Claudio Takahasi [this message]
2005-09-14 15:16 ` Marcel Holtmann
2005-09-14 16:06 ` Claudio Takahasi
2005-09-15 8:11 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1effdeb0509140500650ec0c0@mail.gmail.com \
--to=cktakahasi@gmail.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).