All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Takahasi <cktakahasi@gmail.com>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] HCID D-Bus (Seg Fault)
Date: Tue, 13 Sep 2005 10:03:37 -0300	[thread overview]
Message-ID: <e1effdeb05091306033c7476a@mail.gmail.com> (raw)
In-Reply-To: <1126567316.5518.9.camel@localhost.localdomain>


[-- Attachment #1.1: Type: text/plain, Size: 932 bytes --]

Hi Marcel,

The patch for reply_handler_function is attached.

Regards,
Claudio.

On 9/12/05, Marcel Holtmann <marcel@holtmann.org> wrote:
> 
> Hi Claudio,
> 
> > Regarding the reply_handler_function, please check if it is relevant.
> > I you want I can send only the changes for handle the error messages.
> 
> please do so.
> 
> Regards
> 
> Marcel
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle 
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>

[-- Attachment #1.2: Type: text/html, Size: 1425 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hcid_dbus_0003.patch --]
[-- Type: text/x-patch; name="hcid_dbus_0003.patch", Size: 1998 bytes --]

--- bluez-utils-2.21.orig/hcid/dbus.c	2005-08-27 10:37:14.000000000 -0300
+++ bluez-hcid-2.21/hcid/dbus.c	2005-09-13 09:01:20.409052488 -0300
@@ -68,27 +68,43 @@
 	pin_code_reply_cp pr;
 	DBusMessage *message;
 	DBusMessageIter iter;
-	int type;
+	int arg_type;
+	int msg_type;
 	size_t len;
 	char *pin;
+	const char *error_msg;
 
 	message = dbus_pending_call_steal_reply(call);
 
-	if (dbus_message_is_error(message, WRONG_ARGS_ERROR))
-		goto error;
-
+	if (message) {
+		msg_type = dbus_message_get_type(message);
 	dbus_message_iter_init(message, &iter);
 
-	type = dbus_message_iter_get_arg_type(&iter);
-	if (type != DBUS_TYPE_STRING)
-		goto error;
+		if (msg_type == DBUS_MESSAGE_TYPE_ERROR) {
+#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
+		        dbus_message_iter_get_basic(&iter, &error_msg);
+#else
+		        erro_msg = dbus_message_iter_get_string(&iter);
+#endif
+			/* 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 {
 #ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	dbus_message_iter_get_basic(&iter, &pin);
 #else
 	pin = dbus_message_iter_get_string(&iter);
 #endif
-
 	len = strlen(pin);
 
 	memset(&pr, 0, sizeof(pr));
@@ -97,15 +113,12 @@
 	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);
 }
 
 static void free_pin_req(void *req)

  reply	other threads:[~2005-09-13 13:03 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                   ` Claudio Takahasi [this message]
2005-09-13 18:54                     ` [Bluez-devel] HCID D-Bus (Seg Fault) Marcel Holtmann
2005-09-14 12:00                       ` Claudio Takahasi
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=e1effdeb05091306033c7476a@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.