[Developers] [Fwd: A couple of suggestions for ADMB]

dave fournier davef at otter-rsch.com
Fri Apr 9 05:00:06 PDT 2010


John Sibert wrote:ember.

It just goes back to when the code was running on a DOS machine i.e 1990.
why I stuck it there I can't remember. It is already fixed on the SPC
version, but the official version should have a better solution.
As Shelton pointed out the filenames are in a fixed size array. In
priniciple this is asking for a buffer overflow exploit.
It best would be to turn them into adstrings.  the varssave thing is
around line 200-210 in gradstak.cpp.

> Anybody understand this issue? It seems quintessentially windoze.
>
> -------- Original Message --------
> Subject:     A couple of suggestions for ADMB
> Date:     Thu, 08 Apr 2010 13:43:22 +1100
> From:     Fabrice Bouye <FabriceB at spc.int>
> To:     John Sibert <sibert at hawaii.edu>
> CC:     Shelton Harley <SheltonH at spc.int>, Simon Hoyle
> <SimonH at spc.int>, "nickd at spc.int" <NickD at spc.int>, "Adam Langley (NZ)"
> <adam_langley at xtra.co.nz>
>
>
>
> Hi,
>
> I have a couple or suggestions for ADBM that I have been bickering
> about with Dave over the past couple of days and Shelton has suggested
> that it would probably be good to send that over to the ADMB group.
>
> 1) Nick and Adam have had problems in the past when running MFCL on
> Windows Vista when the program is on the C: drive and we discovered
> the exact same issues when doing some tests on Simon Hoyle’s latop. So
> far, it appears the issue is not caused by MFLC code but by ADMB which
> tries to create a temporary file (varssave.tmp) on the root of the
> current drive* to store temporary gradient (see gradstak.cpp). Of
> course writing on C: is usually forbidden on Vista (even when you are
> an admin) and probably on 7 too.
>
> *Nick and Adam solution was to move the executable to another
> partition and to run from it because you are allowed to write on
> other’s partitions’ roots.
>
> I do not find normal that these temp files are created in a
> centralized location especially when nowadays we may end running
> several instances of MFLC at once on the same computer. They should be
> created in a user accessible temp folder (see below - which is
> probably the case for the Linux version) and should be time stamped
> (+user stamped on Linux) to avoid collision when doing multiple runs.
>
> Note: this apply to other temp files as well not just varssave.tmp.
> Sometime an error happens with cmpdiff.tmp on Linux.
>
> 2) The location of the files can be tweaked by using the sys variable
> ADTMP1. This location is concatenated to the temp filenames using the
> old sprintf() C function. However the temp variables described in
> fvar.hpp only reserve 61 characters for the entire filepath :
>
> gradstak.cpp
>
> path = getenv("ADTMP1"); // NULL if not defined
>
> #if defined(USE_ADPVM)
>
> adstring string_path2;
>
> if (path) string_path2=path;
>
> string_path2+=ad_comm::subdir;
>
> path=(char*) string_path2;
>
> #endif
>
> if (path != NULL)
>
> {
>
> #if defined ( __SUN__) || defined ( __GNU__) || defined(linux)
>
> if (strlen(path)>0)
>
> {
>
> sprintf(&var_store_file_name[0],"%s/varssave.%s",path,
>
> ad_random_part);
>
> sprintf(&gradfile_name2[0],"%s/gradfil2.%s", path,
>
> ad_random_part);
>
> }
>
> else
>
> {
>
> sprintf(&var_store_file_name[0],"varssave.tmp");
>
> sprintf(&gradfile_name2[0],"gradfil2.tmp");
>
> }
>
> #else
>
> if (lastchar(path)!='\\')
>
> {
>
> sprintf(&gradfile_name2[0],"%s\\gradfil2.%s", path,
>
> ad_random_part);
>
> // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>
> // change it to write into cwd
>
> //
>
> //sprintf(&var_store_file_name[0],"%s\\varssave.%s",path,
>
> sprintf(&var_store_file_name[0],"varssave.%s",path,
>
> ad_random_part);
>
> }
>
> else
>
> {
>
> sprintf(&gradfile_name2[0],"%sgradfil2.%s", path,
>
> ad_random_part);
>
> sprintf(&var_store_file_name[0],"%svarssave.%s",path,
>
> ad_random_part);
>
> }
>
> #endif
>
> }
>
> else
>
> {
>
> sprintf(&gradfile_name2[0],"gradfil2.%s",
>
> ad_random_part);
>
> sprintf(&var_store_file_name[0],"varssave.%s",
>
> ad_random_part);
>
> }
>
> create_gradfile();
>
> fvar.hpp
>
> char gradfile_name[61];
>
> char gradfile_name1[61];
>
> char gradfile_name2[61];
>
> char var_store_file_name[61];
>
> So if we define ADTMP1 and specify a path too long MFCL crashes in the
> end. If we are to work in the user’s regular temporary or document
> space on most recent version versions of windows, this is not
> acceptable as these values are too small (the runs will occur in an
> unique temp folder created using the current timestamp so this add
> 10~20 characters to the pathname):
>
> 2000, XP:
>
> Temp space: C:\Documents and Settings\<usermane>\Local Settings\Temp
>
> Document space: C:\Documents and Settings\<usermane>\<My Documents –
> subject to i18n>\<Some subfolder – subject to i18n>
>
> Vista & 7
>
> Temp space: C:\users\<usermane>\AppData\local\Temp
>
> Document space: C:\users\<usermane>\Documents\<Some subfolder –
> subject to i18n>
>
> Linux:
>
> Temp space: /tmp
>
> Document space: $(HOME)/<Some subfolder> or $(HOME)/Desktop/<Some
> subfolder>
>
> Note: i18n = internationalization. IE :
>
> On 2000/XP, pathes are localized to the user’s language.
>
> English XP:
>
> C:\Documents and Settings\<usermane>\Desktop\
>
> C:\Documents and Settings\<usermane>\My Documents\
>
> French XP:
>
> C:\Documents and Settings\<usermane>\Bureau\
>
> C:\Documents and Settings\<usermane>\Mes Documents\
>
> On Vista/7 the REAL paths are always in English but will appear
> localized when viewed in Explorer
>
> English 7:
>
> C:\users\<usermane>\Desktop\
>
> French 7:
>
> C:\users\<usermane>\Desktop\ (will appear as
> C:\utilisateurs\<usermane>\Bureau\ when viewed in Explorer)
>
> ----
> Fabrice Bouyé (http://fabricebouye.cv.fm/)
> Fisheries IT Specialist
> Tel: +687 26 20 00 (Ext 411)
> Oceanic Fisheries, Pacific Community
> http://www.spc.int/
>
>



More information about the Developers mailing list