roxen.lists.roxen.general

Subject Author Date
POST cgi execute fails with so many form variables Eiichiro ITANI <emu[at]ceres[dot]dti[dot]ne[dot]jp> 25-06-2008
Dear Roxen developers,

I have experiencing a problem.  When many many form variables
supplied(I know it's not nice way), cgi execution fails at run()
function in modules/scripting/cgi.pike.  the source is:

#ifdef __NT__
    if(!(pid = Process.create_process( nt_opencommand(command, arguments),
                                       options )))
#else
    if(!(pid = Process.create_process( ({ command }) + arguments, options )))
#endif /* __NT__ */
      error("Failed to create CGI process.\n");
    if(query("kill_call_out"))
      call_out( kill_script, query("kill_call_out")*60 );
    return this_object();

and error message is below:

  Internal server error: Process.create_process(): Arglist too long.


When so many and long form variables names/values pairs supplied,
"arguments" may become so long and excess ARG_MAX,
and Process.create_process fails with E2BIG error.

It also may be dangerous that execute cgi process with query string
set as command line arg, so I modified cgi.pike as below, omit
arguments parameter:

    if(!(pid = Process.create_process( ({ command }) , options )))


But Process.create_process still fails with E2BIG, because
options["env"] become too long.

I checked build_roxen_env_vars() in etc/modules/Roxen.pmod and noticed
one form variable's value was bigger than 8192,  QUERY_xxx AND VAR_xxx
setting be skipped.  But when many-many-many form variables supplied,
total length of environment variable mapping may excess ARG_MAX.


If CGI is called with POST method with so many form vars, it'll be
nice to retry Process.create_process with no QUERY_xxx AND VAR_xxx
set.  Or check request method and total length of QUERY_xxx AND
VAR_xxx key/value pairs at build_roxen_env_vars() funtion.


But, how to do this? X-(


--
  Eiichiro ITANI
  <emu[at]ceres.dti.ne.jp>