From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.devel Subject: Re: dbusbind.c SIGSEGV fix and minor cleanup Date: Sat, 22 Mar 2008 13:55:19 +0100 Organization: disorganized Message-ID: <87abkq3olk.fsf@localhorst.mine.nu> References: <87wso0nz34.fsf@localhorst.mine.nu> <87hcf0kppg.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1206191653 7098 80.91.229.12 (22 Mar 2008 13:14:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Mar 2008 13:14:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 22 14:14:43 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jd3YW-00066R-KW for ged-emacs-devel@m.gmane.org; Sat, 22 Mar 2008 14:14:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jd3Xv-0003tK-7K for ged-emacs-devel@m.gmane.org; Sat, 22 Mar 2008 09:14:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jd3Si-00029z-K0 for emacs-devel@gnu.org; Sat, 22 Mar 2008 09:08:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jd3Se-00029C-SE for emacs-devel@gnu.org; Sat, 22 Mar 2008 09:08:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jd3Sc-00028q-K7 for emacs-devel@gnu.org; Sat, 22 Mar 2008 09:08:35 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jd3Sb-0000pA-Pb for emacs-devel@gnu.org; Sat, 22 Mar 2008 09:08:34 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Jd3ST-0004zo-EP for emacs-devel@gnu.org; Sat, 22 Mar 2008 13:08:25 +0000 Original-Received: from e178010172.adsl.alicedsl.de ([85.178.10.172]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 22 Mar 2008 13:08:25 +0000 Original-Received: from david.hansen by e178010172.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 22 Mar 2008 13:08:25 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 137 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178010172.adsl.alicedsl.de Mail-Copies-To: nobody User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:K6/FwT8af5vMSfro6M/pH74rkmk= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:93178 Archived-At: --=-=-= On Fri, 21 Mar 2008 17:27:07 +0100 Michael Albinus wrote: > David Hansen writes: > >> Hello, > > Hi, > >> 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'. > > One could argue, that in case interface or member is NULL, this could be > regarded as wildcards, and all registered functions which match At least with my dbus installation there is still an error coming to the actual connection. This empty message is hard to reproduce as it seem to happen more or less randomly. In case you wonder how I found out: I debugged a program with gud that crashed after receiving a dbus message from the same emacs process. In some cases emacs just died with it. > One minor point: before "RETURN_UNGCPRO (Qnil)" you might call > "dbus_message_unref (dmessage)" for freeing dmessage. Or you simply jump > to the end, where it is done. Thanks for reviewing and pointing that out. > Please commit the patch, or (in case you have no write access in CVS) > send the ChangeLog entry; I'll do it then. 2008-03-22 David Hansen dbusbind.c: (xd_read_message): Removed extra copying of message strings. Check for NULL `interface' or `member'. --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** dbusbind.c.~1.22.~ 2008-02-17 01:40:28.000000000 +0100 --- dbusbind.c 2008-03-22 09:12:04.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)) ! goto cleanup; 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)), *************** *** 1235,1241 **** value = CDR_SAFE (value); } ! /* Cleanup. */ dbus_message_unref (dmessage); RETURN_UNGCPRO (Qnil); } --- 1233,1239 ---- value = CDR_SAFE (value); } ! cleanup: dbus_message_unref (dmessage); RETURN_UNGCPRO (Qnil); } --=-=-=--