apache - Is there a special case in Apache2 when calling a CGI and the URI includes a single query string parameter without a value? -


today got error , surprised since looked fine...

i have cgi written in c++ accepts uris query string. query string selects page, etc. cgi installed in standard location ubuntu installation:

/usr/lib/cgi-bin/snapmanager.cgi 

today finishing adding login screen , once logged in, wanted add logout link. link adds ?logout @ end of uri:

http://www.example.com/cgi-bin/snapmanager.cgi?logout 

that failed.

checking error log, got error saying "logout" appeared on command line. rather surprising, if ask me! tried with:

http://www.example.com/cgi-bin/snapmanager.cgi?logout=now 

and worked expected. no logout on command line.

i tried:

http://www.example.com/cgi-bin/snapmanager.cgi?logout&host=foo 

and worked too. again, no logout on command line.

however, if switch parameters position fails again:

http://www.example.com/cgi-bin/snapmanager.cgi?host=foo&logout 

so looks apache2 calls cgi logout query string parameter on command line when 1 query string name defined last.

just in case, tried add dashes @ start of name, , sure enough, appears command line switch in logs!

error:snapmanager.cgi: option --logout not supported. 

really scary. huge security risk if know of switch can "tweak things way"...

is documented somewhere?

i found answer in rfc3875 in paragraph 4.4

4.4. script command line

some systems support method supplying array of strings cgi script. used in case of 'indexed' http query, identified 'get' or 'head' request uri query string not contain unencoded "=" characters. such request, server should treat query-string search-string , parse words, using rules

 search-string = search-word *( "+" search-word )  search-word   = 1*schar  schar         = unreserved | escaped | xreserved  xreserved     = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "," |                  "$" 

after parsing, each search-word url-decoded, optionally encoded in system-defined manner , added command line argument list.

if server cannot create part of argument list, server must not generate command line information. example, number of arguments may greater operating system or server limits, or 1 of words may not representable argument.

the script should check see if query_string value contains unencoded "=" character, , should not use command line arguments if does.

emphasis mine


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -