Bug 11146 - httpd_indexcgi.c not working
Summary: httpd_indexcgi.c not working
Status: RESOLVED WORKSFORME
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-11 04:29 UTC by jc
Modified: 2018-07-13 16:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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) {
...