[Bf-committers] Long plugin path problem

Stephane SOPPERA bf-committers@blender.org
Mon, 22 Sep 2003 18:56:08 +0200


> Although not all blender code has been adapted for it, our standard is:
>
> ../blenlib/intern/util.c:#define FILE_MAXDIR  160
> ../blenlib/intern/util.c:#define FILE_MAXFILE 80
>
> The total filename+path therefore is 240 max. The define is a bit  
> confusing here... 'file' is the actual file name, not its entire path.


I think it would be wise to banish strcpy from blender sources and 
replace all of them with strncpy (using the correct size for n, actually 
using strncpy could force the coder to check the validity of what he is 
trying to do. I said "could" since I know that there will still be 
people who won't check). That wouldn't solve issues like the one I found 
but it will prevent memory corruption (and in many situations core dump)

Actually I now understand why the image selector was core-dumping when 
it was trying to list my home directory.
I found that I have a file which name was 150 characters long, and 
another strcpy must have corrupted the memory ;-)

I think that could also explain another bug I've seen on a computer 
where I tried to run blender 2.25 long time ago.

This issue is quite annoying and make blender a very not reliable tool. 
Now that all modern systems supports long file names, 80 characters for 
file name and 160 for path are really short lengths. It could be a 
problem for people which are using long filename and many subdirectories 
(as I have)

> The two .h files related to plugins have now:
> DNA_texture_types.h: 160 chars
> DNA_sequence_types.h 80 chars
>
> Bad bad! :) 

you said it ;-)

> Although I 99.99% sure know that goes well, I hesitate to change this  
> in the code without a test. No time for me to do it now. Another 
> reason  for it you'll read in a next mail I'll send. 

ok

> What I just did was increasing the texture plugin path button max 
> size  to 160. 

That's a good step forward ;-)

Thanks,

> -Ton-
>
>
> On Monday, Sep 22, 2003, at 00:16 Europe/Amsterdam, Robert Wenzlaff  
> wrote:
>
>> On Sunday 21 September 2003 05:48 pm, Stephane SOPPERA wrote:
>>
>>>> Hi!
>>>>
>>>> I noticed today that the path of sequence plugins is limited to 80
>>>> caracters (name member of the PluginSeq struct) and that strcpy is
>>>> used to copy the path in this variable. So the memory is corrupted
>>>> when the path for a plugin is longer than 80 characters (that's the
>>>> case of many plugins on my system) and the plugin don't work ;-)
>>>>
>>>> An easy fix would be to set a bigger limit (bigger than FILE_MAXDIR
>>>> which is quite small and lesser than PATH_MAX on my system). A better
>>>> fix should be to use a C++ class for strings ;-)
>>>
>>
>> Well since most of the code is in straight C, the second option is a  
>> bit
>> tedious...
>>
>> _POSIX_PATH_MAX is 256, so there's no reason to make it longer than  
>> that.  And
>> it even pads the DNA nicely.   And in the big picture, really isn't  
>> that much
>> wasted memory.
>>
>> --  ********************************************
>>        I prefer Rush to G. Gordon Liddy.
>>         After all, the Watergate Tapes
>>         can't hold a candle to either
>>          "2112" or "Moving Pictures".
>> ********************************************
>> Robert Wenzlaff  rwenzlaff@soylent-green.com
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers@blender.org
>> http://www.blender.org/mailman/listinfo/bf-committers
>>
>>
> ------------------------------------------------------------------------ 
> -- 
> Ton Roosendaal  Blender Foundation ton@blender.org  
> http://www.blender.org
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers@blender.org
> http://www.blender.org/mailman/listinfo/bf-committers
>


-- 
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera