bug-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Segfault in 2.05pre2 on Sol-X86


From: Marion Hakanson
Subject: Re: Segfault in 2.05pre2 on Sol-X86
Date: Mon, 30 Dec 2002 14:35:05 -0800

Folks,

We see a segfault here with cfengine-2.0.5pre2, on Solaris-8 & -9
on the SPARC platform.  It happens at our first "editfiles" item.

I had noticed 2 weeks ago a possible problem while looking at the new
(pre2) code in src/varstring.c, the ExpandVarString() routine, and sent a
patch to the author directly (he's been busy and evidently hasn't gotten
it applied yet).  When I apply the following patch, the problem goes away:

============================================================
--- varstring.c.bak     2002-11-28 13:41:18.000000000 -0800
+++ varstring.c 2002-12-04 11:56:47.795209000 -0800
@@ -201,24 +201,29 @@
   time_t tloc;
   
 
-bzero(buffer,bufsize);
+buffer[0] = '\0';
+
+if (string == 0 || strlen(string) == 0)
+   {
+   return false;
+   }
+
 bzero(cleaned,bufsize);
+i = j = 0;
  
-for (i = j = 0; string[i] != '\0'; i++,j++)
+while (i < bufsize && string[i] != '\0')
    {
-   if (string[i] == '/' && string[i+1] == '/')
+   if (i > 0 && string[i] == '/' && string[i-1] == '/')
       {
       i++;
       }
-   cleaned[j] = string[i];
+   else
+      {
+      cleaned[j++] = string[i++];
+      }
    }
 
  
-if (string == 0 || strlen(string) == 0)
-   {
-   return false;
-   }
-
 for (sp = cleaned; /* No exit */ ; sp++)       /* check for varitems */
    {
    currentitem[0] = '\0';
============================================================

Regards,

-- 
Marion Hakanson <address@hidden>
CSE Computing Facilities





reply via email to

[Prev in Thread] Current Thread [Next in Thread]