Subject: segfault: "Key" without any arguments

From: Frank Gruellich <[email-masked]>
Date: Thu, 20 Jan 2005 01:51:43 +0100

Hello,

I dunno, maybe I've done something really bad but I think, it shouldn't
crash.  I disabled all configurations (no .fvwm2rc) and at the default
"Issue FVWM command" I issued "Key" (or "Mouse").  I "forgot" the
arguments and fvwm segfaults.

(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
ParseBinding (dpy=0x8102730, pblist=0x80f8d38, tline=0x811fb2b "",
    type=BIND_KEYPRESS, nr_left_buttons=0x80fb2e4, nr_right_buttons=0x80fb2e8,
    buttons_grabbed=0xbfffefda, is_silent=0) at bindings.c:262
262             if (*p == '(')
(gdb) bt
#0  ParseBinding (dpy=0x8102730, pblist=0x80f8d38, tline=0x811fb2b "",
    type=BIND_KEYPRESS, nr_left_buttons=0x80fb2e4, nr_right_buttons=0x80fb2e8,
    buttons_grabbed=0xbfffefda, is_silent=0) at bindings.c:262
#1  0x080b9cff in binding_cmd (cond_rc=0xbffff070, exc=0x811f850, action=0x0,
    type=BIND_KEYPRESS) at bindings.c:576
#2  0x080b9db8 in CMD_Key (cond_rc=0x0, exc=0x0, action=0x0) at bindings.c:610
#3  0x080a6493 in __execute_function (cond_rc=0x0, exc=0x811f5f8,
    action=0x811f850 "M", exec_flags=0 '\0', args=0x811fb28) at functions.c:630
#4  0x080a732d in execute_function (cond_rc=0x0, exc=0x0, action=0x0,
    exec_flags=0 '\0') at functions.c:1247
#5  0x0808e67a in ExecuteModuleCommand (w=0, module=0, text=0x811fb50 "Key")
    at module_interface.c:711
#6  0x08090045 in ExecuteCommandQueue () at module_interface.c:1814
#7  0x080660e8 in My_XNextEvent (dpy=0x8102730, event=0xbffff370)
    at events.c:4050
#8  0x08065e50 in HandleEvents () at events.c:3847
#9  0x0808c356 in main (argc=1, argv=0xbffff824) at fvwm.c:2520
(gdb)

Using CVS, it seems, ParseBinding is broken now[1].  As mentioned before
I am by far no coder, maybe this is the very wrong place to do this, but
I just catched the p == 0:

--- fvwm/bindings.c	2005-01-20 01:38:29.778605931 +0100
+++ fvwm/bindings.c.orig	2005-01-20 01:38:53.494448040 +0100
@@ -259,12 +259,6 @@
 	/* tline points after the key word "Mouse" or "Key" */
 	token = p = PeekToken(tline, &ptr);
 	/* check to see if a window name has been specified. */
-	if (p == NULL)
-	{
-		fvwm_msg(
-			ERR, "ParseBinding", "empty line\n");
-		return 0;
-	}
 	if (*p == '(')
 	{
 		/* A window name has been specified for the binding. */

HTH,
 regards, Frank.
===footnotes===
[1] It's not in my distributions version:
fvwm 2.5.10 compiled on Jun  4 2004 at 01:39:54
with support for: ReadLine, Stroke, XPM, PNG, Shape, XShm, SM, Xinerama, XRender, XFT, NLS
-- 
,------------------------.------------------------.--------------------.
| Chemnitzer Linux-Tage  | "Linux loves desktops" ' [email-masked] |
| March, 5th + 6th, 2005 |       http://chemnitzer.linux-tage.de/      |
'------------------------'---------------------------------------------'
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Wed, 19 Jan 2005 21:17:59 -0500

> arguments and fvwm segfaults.

I've applied your patch to CVS.

Thanks.
-- 
Dan Espen                           E-mail: [email-masked]