Subject: Re: `Direction' core dumps

From: Dominik Vogt <[email-masked]>
Date: Wed, 10 Feb 1999 19:37:18 +0100

On Mon, Feb 08, 1999 at 02:11:27PM +0100, Ives Aerts wrote:
> On Mon, Feb 08, 1999 at 01:36:10PM +0100, Dominik Vogt wrote:
> > Could you change this to
> > [snip]
> > And see if Action is a NULL pointer?
> 
> It seems to be even worse:
> 
>   [FVWM][CreateConditionMask]: <<ERROR>> Conditionals require closing
>   parenthesis
>   Action = 0x00000009
>   ÿÿÿÿSegmentation fault (core dumped)

OK, here's the patch (applies to 2.1.10 and current CVS source).

Please ckeck if it fixes the coredump and post a reply to the list.

Bye

Dominik

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]

--- ChangeLog.orig	Tue Feb  9 20:42:33 1999
+++ ChangeLog	Tue Feb  9 20:52:34 1999
@@ -1,3 +1,16 @@
+1999-02-09  Dominik Vogt  <[email-masked]>
+
+	* fvwm/builtins.c (CreateFlagString): corrected restptr to return NULL
+	on error
+	(PrevFunc): check for NULL pointer added
+	(NextFunc): check for NULL pointer added
+	(NoneFunc): check for NULL pointer added
+	(CurrentFunc): check for NULL pointer added
+	(DirectionFunc): check for NULL pointer added
+
+	* fvwm/functions.c (ExecuteFunction): check for NULL pointer added
+	(find_func_type): check for NULL pointer added
+
 1999-01-19  Paul D. Smith  <[email-masked]>
 
 	* README: Update new URLs; a few spelling corrections; specify
--- fvwm/builtins.c.orig	Tue Feb  9 20:42:01 1999
+++ fvwm/builtins.c	Tue Feb  9 20:52:27 1999
@@ -4132,6 +4132,7 @@
       if (*c == 0) {
 	fvwm_msg(ERR, "CreateConditionMask",
 		 "Conditionals require closing parenthesis");
+	*restptr = NULL;
 	return NULL;
       }
       c++;
@@ -4412,7 +4413,7 @@
   char *restofline;
 
   found = Circulate(action, -1, &restofline);
-  if(found != NULL)
+  if(found != NULL && restofline != NULL)
   {
     ExecuteFunction(restofline,found,eventp,C_WINDOW,*Module);
   }
@@ -4426,7 +4427,7 @@
   char *restofline;
 
   found = Circulate(action, 1, &restofline);
-  if(found != NULL)
+  if(found != NULL && restofline != NULL)
   {
     ExecuteFunction(restofline,found,eventp,C_WINDOW,*Module);
   }
@@ -4440,7 +4441,7 @@
   char *restofline;
 
   found = Circulate(action, 1, &restofline);
-  if(found == NULL)
+  if(found == NULL && restofline != NULL)
   {
     ExecuteFunction(restofline,NULL,eventp,C_ROOT,*Module);
   }
@@ -4453,7 +4454,7 @@
   char *restofline;
 
   found = Circulate(action, 0, &restofline);
-  if(found != NULL)
+  if(found != NULL && restofline != NULL)
   {
     ExecuteFunction(restofline,found,eventp,C_WINDOW,*Module);
   }
@@ -4513,6 +4514,12 @@
 
   /* Create the mask for flags */
   flags = CreateFlagString(action, &restofline);
+  if (!restofline)
+  {
+    if (flags)
+      free(flags);
+    return;
+  }
   DefaultConditionMask(&mask);
   CreateConditionMask(flags, &mask);
   if (flags)
--- fvwm/functions.c.orig	Tue Feb  9 20:42:25 1999
+++ fvwm/functions.c	Tue Feb  9 20:45:33 1999
@@ -225,7 +225,9 @@
   char *arguments[10];
   struct functions *bif;
 
-  if (Action[0] == 0 || Action[1] == 0){/* impossibly short command */
+  if (!Action || Action[0] == 0 || Action[1] == 0)
+  {
+    /* impossibly short command */
     return;                             /* done */
   }
   if (Action[0] == '#') {               /* a comment */
@@ -294,24 +296,28 @@
   Bool matched;
   int mlen;
 
-  while (*endtok&&!isspace(*endtok))++endtok;
-  len = endtok - action;
-  j=0;
-  matched = FALSE;
-  while((!matched)&&((mlen = strlen(func_config[j].keyword))>0))
-    {
-      if((mlen == len) && (strncasecmp(action,func_config[j].keyword,mlen)==0))
+  if (action)
+  {
+    while (*endtok&&!isspace(*endtok))++endtok;
+    len = endtok - action;
+    j=0;
+    matched = FALSE;
+    while((!matched)&&((mlen = strlen(func_config[j].keyword))>0))
       {
-	  matched=TRUE;
-	  /* found key word */
-	  *func_type = func_config[j].func_type;
-	  *func_needs_window = func_config[j].func_needs_window;
-	  return;
+	if((mlen == len) &&
+	   (strncasecmp(action,func_config[j].keyword,mlen)==0))
+	  {
+	    matched=TRUE;
+	    /* found key word */
+	    *func_type = func_config[j].func_type;
+	    *func_needs_window = func_config[j].func_needs_window;
+	    return;
+	  }
+	else
+	  j++;
       }
-      else
-	j++;
-    }
-  /* No clue what the function is. Just return "BEEP" */
+    /* No clue what the function is. Just return "BEEP" */
+  }
   *func_type = F_BEEP;
   *func_needs_window = False;
   return;

--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
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: Ives Aerts <[email-masked]>
Date: Thu, 11 Feb 1999 10:12:51 +0100

> Please ckeck if it fixes the coredump and post a reply to the list.

I just checked and it works. I get a nice error message now and it
doesn't core dump anymore.

Cheers,
-Ives
______________________________________________________________________
Ives Aerts (R&D Software engineer)           Sony DNSE-Brussels
[email-masked]                       St.Stevens Woluwestr. 55
`It always takes longer than expected, even  B-1130 Brussels, Belgium
 if you take into account Hofstadter's law'  PHONE : +32 2 724 86 11
                          (Hofstadter's law) FAX   : +32 2 724 86 88
--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
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: Dominik Vogt <[email-masked]>
Date: Thu, 11 Feb 1999 10:26:38 +0100

> doesn't core dump anymore.

Good. I will check in the patch soon.

Bye

Dominik

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
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].