Seg fault when trying to pass a scalar as a list

Jonathan Clarke <[email protected]> Mon, 07 Dec 2009 12:27:16 +0100
Newsgroups gmane.comp.sysutils.cfengine.bugs
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------010203000407040304050603
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Consider this promise:
8<---------
body common control { 
 

     bundlesequence => { "mybundle" };
}

bundle agent mybundle {
     vars:
         "name" string => "jonathan";

     commands:
         "/bin/echo"
             args => "@(name)";
}
8<---------

Running this through cf-promises or cf-agent causes a SEGFAULT (using 
versions compiled from svn trunk).

Obviously, this is silly (using @ on a scalar var). However, I feel a 
SEGFAULT should be avoided, since it will break any other following 
promises.

I have attached a patch against SVN trunk, which corrects the problem. 
I'm not sure however that this is the best way to do so... I'm new to 
this code :)

Regards,
Jonathan
-- 
--------------------------------------------------------------
Jonathan Clarke - [email protected]
--------------------------------------------------------------
Ldap Synchronization Connector (LSC) - http://lsc-project.org
--------------------------------------------------------------

--------------010203000407040304050603
Content-Type: text/x-patch;
 name="cfengine-bug-list-expand-scalar.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="cfengine-bug-list-expand-scalar.patch"

Index: expand.c
===================================================================
--- expand.c	(revision 657)
+++ expand.c	(working copy)
@@ -641,7 +641,7 @@
    {
    GetNaked(naked,rval);
    
-   if (GetVariable(scopeid,naked,&(returnval.item),&(returnval.rtype)) == cf_notype)
+   if (GetVariable(scopeid,naked,&(returnval.item),&(returnval.rtype)) == cf_notype || returnval.rtype != CF_LIST)
       {
       returnval = ExpandPrivateRval("this",rval,rtype);
       }

--------------010203000407040304050603
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

--------------010203000407040304050603--