[Bf-committers] makesdna problem?

Ton Roosendaal ton at blender.org
Sat Oct 30 14:02:25 CEST 2004


Hi,

I found out the makesdna code doesnt check for total size of structs,  
for example when you add 1 byte to the end, no complaint is given.
That's usually no problem (malloc gives multiples of 4 bytes, file  
saves that too), but when you use struct arrays that goes wrong.

Adding a test for this case, gave error in this struct:

typedef struct WipeVars {
	float edgeWidth,angle;
	short forward,spad1,spad2,spad3;
	int ipad1;
	float fpad1,fpad2;
	short wipetype;
} WipeVars;

The creator of this struct clearly is *very* afraid for sdna! :)
It can simply be:

typedef struct WipeVars {
	float edgeWidth, angle;
	short forward, wipetype;
} WipeVars;

-Ton-


On 30 Oct, 2004, at 12:34, Alexander Ewering wrote:

>
> On Sat, 30 Oct 2004, Ton Roosendaal wrote:
>
>> Hi,
>>
>> Makesdna complains here all the time, dunno why it didn't in this  
>> case... you can simply test it by adding 1 byte to a random struct.  
>> Might be a makefile issue though, with a dependency missing for check  
>> on standard includes.
>
> Ton,
>
> maybe it doesn't find this issue because the Layer array is statically
> allocated? I.e., the parser doesn't care about [] arrays?
>
> The strange thing was that as soon as I added 3 padding chars to the
> typedef of the Layer struct, I suddenly got a sizeerror in struct  
> Scene,
> which I had to cure by adding another pad int to struct Scene.
>
> But it never said anything about struct Layer and the problems its odd
> size caused.
>
> I consider this worth some investigation, as such bugs will become
> very hard to trace if they sneak in without notice. Random mem/file
> corruption.
>
> | alexander ewering              instinctive mediaworks
> | ae[@]instinctive[.]de   http://www[.]instinctive[.]de
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
>
>
------------------------------------------------------------------------ 
--
Ton Roosendaal  Blender Foundation ton at blender.org  
http://www.blender.org



More information about the Bf-committers mailing list