unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Hansen <david.hansen@gmx.net>
To: emacs-devel@gnu.org
Subject: dbusbind.c SIGSEGV fix and minor cleanup
Date: Tue, 18 Mar 2008 10:47:11 +0100	[thread overview]
Message-ID: <87wso0nz34.fsf@localhorst.mine.nu> (raw)

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

Hello,

emacs crashes (in `strcpy') when receiving dbus messages with some empty
content.

The attached patch fixes this.  Also there is no need to copy the
strings.  This is already be done by `build_string'.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2794 bytes --]

*** dbusbind.c.~1.22.~	2008-02-17 01:40:28.000000000 +0100
--- dbusbind.c	2008-03-18 10:35:30.000000000 +0100
***************
*** 1140,1149 ****
    DBusMessageIter iter;
    unsigned int dtype;
    int mtype;
!   char uname[DBUS_MAXIMUM_NAME_LENGTH];
!   char path[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; /* Unlimited in D-Bus spec.  */
!   char interface[DBUS_MAXIMUM_NAME_LENGTH];
!   char member[DBUS_MAXIMUM_NAME_LENGTH];
  
    /* Open a connection to the bus.  */
    connection = xd_initialize (bus);
--- 1140,1146 ----
    DBusMessageIter iter;
    unsigned int dtype;
    int mtype;
!   const char *uname, *path, *interface, *member;
  
    /* Open a connection to the bus.  */
    connection = xd_initialize (bus);
***************
*** 1175,1185 ****
  
    /* Read message type, unique name, object path, interface and member
       from the message.  */
!   mtype =            dbus_message_get_type (dmessage);
!   strcpy (uname,     dbus_message_get_sender (dmessage));
!   strcpy (path,      dbus_message_get_path (dmessage));
!   strcpy (interface, dbus_message_get_interface (dmessage));
!   strcpy (member,    dbus_message_get_member (dmessage));
  
    XD_DEBUG_MESSAGE ("Event received: %d %s %s %s %s %s",
  		    mtype, uname, path, interface, member,
--- 1172,1186 ----
  
    /* Read message type, unique name, object path, interface and member
       from the message.  */
!   mtype     = dbus_message_get_type (dmessage);
!   uname     = dbus_message_get_sender (dmessage);
!   path      = dbus_message_get_path (dmessage);
!   interface = dbus_message_get_interface (dmessage);
!   member    = dbus_message_get_member (dmessage);
! 
!   /* dbus-registered-functions-table requires non nil interface and member. */
!   if ((NULL == interface) || (NULL == member))
!     RETURN_UNGCPRO (Qnil);
  
    XD_DEBUG_MESSAGE ("Event received: %d %s %s %s %s %s",
  		    mtype, uname, path, interface, member,
***************
*** 1210,1220 ****
  			     args);
  
  	  /* Add uname, path, interface and member to the event.  */
! 	  event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
! 			     event.arg);
! 	  event.arg = Fcons ((interface == NULL
! 			      ? Qnil : build_string (interface)),
! 			     event.arg);
  	  event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
  			     event.arg);
  	  event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)),
--- 1211,1218 ----
  			     args);
  
  	  /* Add uname, path, interface and member to the event.  */
! 	  event.arg = Fcons (build_string (member), event.arg);
! 	  event.arg = Fcons (build_string (interface), event.arg);
  	  event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
  			     event.arg);
  	  event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)),

             reply	other threads:[~2008-03-18  9:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-18  9:47 David Hansen [this message]
2008-03-21  2:00 ` dbusbind.c SIGSEGV fix and minor cleanup David Hansen
2008-03-21 16:27 ` Michael Albinus
2008-03-22 12:55   ` David Hansen
2008-03-23 16:55     ` Michael Albinus

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wso0nz34.fsf@localhorst.mine.nu \
    --to=david.hansen@gmx.net \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).