Bug 11146

Summary: httpd_indexcgi.c not working
Product: Busybox Reporter: jc <jc>
Component: NetworkingAssignee: unassigned
Status: RESOLVED WORKSFORME    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description jc 2018-07-11 04:29:08 UTC
By changing line 239
  QUERY_STRING = getenv("QUERY_STRING");
to
  QUERY_STRING = getenv("REQUEST_URI");

The code then works for me.

First contribution, hope I haven't missed something silly.
Comment 1 Denys Vlasenko 2018-07-13 16:33:54 UTC
(In reply to jc from comment #0)
>By changing line 239
>  QUERY_STRING = getenv("QUERY_STRING");
>to
>  QUERY_STRING = getenv("REQUEST_URI");

Er... line 239 "return 1"... and code already uses REQUEST_URI, since version 1.20.x:

...
   215  int main(int argc, char *argv[])
   216  {
   217          dir_list_t *dir_list;
   218          dir_list_t *cdir;
   219          unsigned dir_list_count;
   220          unsigned count_dirs;
   221          unsigned count_files;
   222          unsigned long long size_total;
   223          int odd;
   224          DIR *dirp;
   225          char *location;
   226
   227          location = getenv("REQUEST_URI");
   228          if (!location)
   229                  return 1;
   230
   231          /* drop URL arguments if any */
   232          strchrnul(location, '?')[0] = '\0';
   233
   234          if (location[0] != '/'
   235           || strstr(location, "//")
   236           || strstr(location, "/../")
   237           || strcmp(strrchr(location, '/'), "/..") == 0
   238          ) {
   239                  return 1;
   240          }
   241
   242          if (chdir("..")
   243           || (location[1] && chdir(location + 1))
   244          ) {
   245                  return 1;
   246          }
   247
   248          dirp = opendir(".");
   249          if (!dirp)
   250                  return 1;
   251          dir_list = NULL;
   252          dir_list_count = 0;
   253          while (1) {
...