axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dr. Florian Steinborn" <florian.steinb...@drb.insel.de>
Subject |AXIS2] [AXIS2C] c-stubs: memset in axis2_<TYPE>_create missing
Date Thu, 21 Jun 2007 15:35:30 GMT
Hi group,

I guess I found a problem in generated sources. I try to get in touch with  
Axis and play around with all the things... I have a service that returns  
an array of structures that contain all possible datatypes - also float  
and double.

I used this class for generating the wsdl:


public class Dat{
     public long         l;
     public short        s;
     public int          i;
     public String       str;
     public float        fl;
     public double       dl;
}

The generated wsdl shows

<xs:element name="Dat" type="ns:Dat" />
<xs:complexType name="Dat">
<xs:sequence>
<xs:element name="dl" type="xs:double" />
<xs:element name="fl" type="xs:float" />
<xs:element name="i" type="xs:int" />
<xs:element name="str" nillable="true" type="xs:string" />
<xs:element name="l" type="xs:long" />
<xs:element name="s" type="xs:short" />
</xs:sequence>
</xs:complexType>

When you generate C-Server stubs the constructor function
shows:

AXIS2_EXTERN axis2_Dat_t* AXIS2_CALL
axis2_Dat_create(
     const axutil_env_t *env )
{
     axis2_Dat_t *Dat = NULL;

     AXIS2_ENV_CHECK(env, NULL);

     Dat = (axis2_Dat_t *) AXIS2_MALLOC(env->
         allocator, sizeof(axis2_Dat_t));

     /* **** missing
      * memset( Dat, 0, sizeof(axis2_Dat_t));
      * *****
      */

     if(NULL == Dat)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
     return Dat;
}

For more safety it would be desirable if the generation would add the  
memset() call. I did not initialize every field of the structure before  
returning it and the service crashed (with the server), when it tried to  
return the values. In that the generated function axis2_Date_serialize()  
is called. This function has a problem, as it tries to print (with  
sprintf()) all the numeric members of the Dat-struct into 64-bytes memory  
blocks. Printing a double with sprintf() this way into a 64-byte array  
will most likely crash, especially with uninitialized memory, as the  
resulting string will be longer than 64 bytes.

Unfortunately the user cannot call the memset himself after calling the  
constructor as the real length of the type is hidden in the module. I  
myself now know that I have to call the setter method for each member of a  
new struct.

Thanks,
Flori.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Mime
View raw message