On Wed, 8 Jun 2011 16:29:06 -0300 Lucas De Marchi <lucas.demar...@profusion.mobi> said:
> * Vincent Torri <vto...@univ-evry.fr> [2011-06-08 20:56:52 +0200]: > > > > > > > On Tue, 7 Jun 2011, Lucas De Marchi wrote: > > > > >On Tue, Jun 7, 2011 at 8:24 PM, Vincent Torri <vto...@univ-evry.fr> wrote: > > >> > > >>Hey, > > >> > > >>On windows, using open() followed by fopen() does not work. Hence, in > > >>edje_cc, where mkstemp (which uses open) is followed by fopen, edje_cc > > >>fails. > > >> > > >>Instead of fopen, we can use fdopen. I pasted a patch below. Can you > > >>comment it (like, instead of keeping the filename in the function that i > > >>modified, why not using it for the fd? > > > > > >The patch looks a bit weird. IMO you should take one of the following > > >approaches (in order of preference): > > > > > >1) Pass only the file descriptor instead of the filename. This way you > > >will write to the file descriptor recently opened by mkstemp. > > > > > >2) call close(fd) before calling create_script_file() and > > >compile_script_file(). This is very ugly thing that should work as > > >well, however one might argument that there's a race because the file > > >might disappear between the call to mkstemp() -- its creation -- and > > >the above functions. > > > > woldn't it be better to directly call open, fdopen and close in the > > functions create_script_file() and compile_script_file() ? > > > You actually have no guarantees the file still exists... Someone could > have deleted the file meanwhile. But for this use-case this is just > being paranoid. in this case this is really paranoid. as such the only one who can do this to you is root as only root can delete the file or rename it in the tmp dir. so root can "exploit your edje compile". joy. root can do many other more evil things to make your day hell than this :) > So, the easiest fix (and cleanest in my POV) would be the patch below > (untested); i don't see how this fixes vtoprri's problem. the mkstemp followed by an fopen of that file fails (the fopen does). must be some kind of peculiarity/race etc. in windows. vtorri's soln works well. it doesnt need the closes at all actually as fdopen now will associate the fd with the fstream and close it on flcose i'm happy. with that. i'm putting that into svn unless there is some amazingly better way :) > Lucas De Marchi > > > > Index: src/bin/edje_cc_out.c > =================================================================== > --- src/bin/edje_cc_out.c (revision 59987) > +++ src/bin/edje_cc_out.c (working copy) > @@ -864,8 +864,8 @@ > error_and_abort(ef, "Unable to open temp file \"%s\" for script " > "compilation.\n", tmpn); > > + close(fd); > create_script_file(ef, tmpn, cd); > - close(fd); > > snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); > fd = mkstemp(tmpo); > @@ -876,8 +876,8 @@ > "compilation.\n", tmpn); > } > > + close(fd); > compile_script_file(ef, tmpn, tmpo, i); > - close(fd); > > unlink(tmpn); > unlink(tmpo); > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) ras...@rasterman.com ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel