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: dbusbind.c SIGSEGV fix and minor cleanup Date: Tue, 18 Mar 2008 10:47:11 +0100 Organization: disorganized Message-ID: <87wso0nz34.fsf@localhorst.mine.nu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1205834035 27728 80.91.229.12 (18 Mar 2008 09:53:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2008 09:53:55 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 18 10:54:24 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 1JbYWQ-0008IR-HR for ged-emacs-devel@m.gmane.org; Tue, 18 Mar 2008 10:54:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JbYVq-0004l6-Mt for ged-emacs-devel@m.gmane.org; Tue, 18 Mar 2008 05:53:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JbYVi-0004jL-N0 for emacs-devel@gnu.org; Tue, 18 Mar 2008 05:53:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JbYVg-0004hJ-OA for emacs-devel@gnu.org; Tue, 18 Mar 2008 05:53:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JbYVg-0004gf-AE for emacs-devel@gnu.org; Tue, 18 Mar 2008 05:53:32 -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 1JbYVf-0003d9-DP for emacs-devel@gnu.org; Tue, 18 Mar 2008 05:53:31 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JbYVW-00054U-7H for emacs-devel@gnu.org; Tue, 18 Mar 2008 09:53:22 +0000 Original-Received: from e178054105.adsl.alicedsl.de ([85.178.54.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Mar 2008 09:53:22 +0000 Original-Received: from david.hansen by e178054105.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Mar 2008 09:53:22 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 92 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178054105.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:2M5XGq10rAfPD3M3WJC0dkfaeBA= 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:92880 Archived-At: --=-=-= 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** 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)), --=-=-=--